|
1 |
| -use crate::init::utils::{add_workspace_without_target, standard_options_with_extra_target}; |
| 1 | +use crate::init::utils::{ |
| 2 | + add_workspace_without_target, remove_target, standard_options_with_extra_target, |
| 3 | +}; |
2 | 4 | use crate::init::{StackState, add_stack_with_segments, add_workspace, id_at, id_by_rev};
|
3 | 5 | use crate::init::{read_only_in_memory_scenario, standard_options};
|
4 | 6 | use but_graph::Graph;
|
@@ -2423,7 +2425,7 @@ fn three_branches_one_advanced_ws_commit_advanced_fully_pushed_empty_dependant()
|
2423 | 2425 | ├── ►:1[0]:origin/main →:2:
|
2424 | 2426 | │ └── →:2: (main →:1:)
|
2425 | 2427 | └── ►:4[0]:origin/advanced-lane →:6:
|
2426 |
| - └── →:5: (dependant) |
| 2428 | + └── →:6: (advanced-lane →:4:) |
2427 | 2429 | ");
|
2428 | 2430 |
|
2429 | 2431 | // When putting the dependent branch on top as empty segment, the frozen state is retained.
|
@@ -3241,7 +3243,7 @@ fn dependent_branch_insertion() -> anyhow::Result<()> {
|
3241 | 3243 | ├── ►:1[0]:origin/main →:2:
|
3242 | 3244 | │ └── →:2: (main →:1:)
|
3243 | 3245 | └── ►:4[0]:origin/advanced-lane →:6:
|
3244 |
| - └── →:5: (dependant) |
| 3246 | + └── →:6: (advanced-lane →:4:) |
3245 | 3247 | ");
|
3246 | 3248 |
|
3247 | 3249 | // The dependant branch is empty and on top of the one with the remote
|
@@ -3960,7 +3962,7 @@ fn without_target_ref_or_managed_commit_ambiguous_with_remotes() -> anyhow::Resu
|
3960 | 3962 | ├── ►:2[0]:origin/A →:5:
|
3961 | 3963 | │ └── →:5: (A →:2:)
|
3962 | 3964 | └── ►:3[0]:origin/B →:0:
|
3963 |
| - └── →:5: (A →:2:) |
| 3965 | + └── →:0: (B →:3:) |
3964 | 3966 | ");
|
3965 | 3967 | insta::assert_snapshot!(graph_workspace(&graph.to_workspace()?), @r"
|
3966 | 3968 | 📕🏘️⚠️:1:gitbutler/workspace <> ✓!
|
@@ -5144,6 +5146,105 @@ fn unapplied_branch_on_base() -> anyhow::Result<()> {
|
5144 | 5146 | Ok(())
|
5145 | 5147 | }
|
5146 | 5148 |
|
| 5149 | +#[test] |
| 5150 | +fn unapplied_branch_on_base_no_target() -> anyhow::Result<()> { |
| 5151 | + let (repo, mut meta) = read_only_in_memory_scenario("ws/unapplied-branch-on-base")?; |
| 5152 | + insta::assert_snapshot!(visualize_commit_graph_all(&repo)?, @r" |
| 5153 | + * a26ae77 (HEAD -> gitbutler/workspace) GitButler Workspace Commit |
| 5154 | + * fafd9d0 (origin/main, unapplied, main) init |
| 5155 | + "); |
| 5156 | + add_workspace(&mut meta); |
| 5157 | + remove_target(&mut meta); |
| 5158 | + |
| 5159 | + let graph = Graph::from_head(&repo, &*meta, standard_options())?.validated()?; |
| 5160 | + insta::assert_snapshot!(graph_tree(&graph), @r" |
| 5161 | + ├── 👉📕►►►:0[0]:gitbutler/workspace |
| 5162 | + │ └── ·a26ae77 (⌂|🏘|1) |
| 5163 | + │ └── ►:2[1]:main <> origin/main →:1: |
| 5164 | + │ └── ·fafd9d0 (⌂|🏘|11) ►unapplied |
| 5165 | + └── ►:1[0]:origin/main →:2: |
| 5166 | + └── →:2: (main →:1:) |
| 5167 | + "); |
| 5168 | + |
| 5169 | + // the main branch is disambiguated by its remote reference. |
| 5170 | + insta::assert_snapshot!(graph_workspace(&graph.to_workspace()?), @r" |
| 5171 | + 📕🏘️:0:gitbutler/workspace <> ✓! |
| 5172 | + └── ≡:2:main <> origin/main →:1: |
| 5173 | + └── :2:main <> origin/main →:1: |
| 5174 | + └── ❄️fafd9d0 (🏘️) ►unapplied |
| 5175 | + "); |
| 5176 | + |
| 5177 | + // The 'unapplied' branch can be added on top of that, and we make clear we want `main` as well. |
| 5178 | + add_stack_with_segments(&mut meta, 1, "unapplied", StackState::InWorkspace, &[]); |
| 5179 | + add_stack_with_segments(&mut meta, 2, "main", StackState::InWorkspace, &[]); |
| 5180 | + |
| 5181 | + let graph = Graph::from_head(&repo, &*meta, standard_options())?.validated()?; |
| 5182 | + insta::assert_snapshot!(graph_tree(&graph), @r" |
| 5183 | + ├── 👉📕►►►:0[0]:gitbutler/workspace |
| 5184 | + │ └── ·a26ae77 (⌂|🏘|1) |
| 5185 | + │ ├── 📙►:3[1]:unapplied |
| 5186 | + │ │ └── ►:2[2]:anon: |
| 5187 | + │ │ └── ·fafd9d0 (⌂|🏘|✓|11) |
| 5188 | + │ └── 📙►:4[1]:main <> origin/main →:1: |
| 5189 | + │ └── →:2: |
| 5190 | + └── ►:1[0]:origin/main →:4: |
| 5191 | + └── →:4: (main →:1:) |
| 5192 | + "); |
| 5193 | + |
| 5194 | + insta::assert_snapshot!(graph_workspace(&graph.to_workspace()?), @r" |
| 5195 | + 📕🏘️:0:gitbutler/workspace <> ✓refs/remotes/origin/main on fafd9d0 |
| 5196 | + ├── ≡📙:4:main <> origin/main →:1: on fafd9d0 |
| 5197 | + │ └── 📙:4:main <> origin/main →:1: |
| 5198 | + └── ≡📙:3:unapplied on fafd9d0 |
| 5199 | + └── 📙:3:unapplied |
| 5200 | + "); |
| 5201 | + |
| 5202 | + // We simulate an unapplied branch on the base by giving it branch metadata, but not listing |
| 5203 | + // it in the workspace. |
| 5204 | + add_stack_with_segments(&mut meta, 1, "unapplied", StackState::Inactive, &[]); |
| 5205 | + let graph = Graph::from_head(&repo, &*meta, standard_options())?.validated()?; |
| 5206 | + |
| 5207 | + // Now only `main` shows up. |
| 5208 | + insta::assert_snapshot!(graph_workspace(&graph.to_workspace()?), @r" |
| 5209 | + 📕🏘️:0:gitbutler/workspace <> ✓refs/remotes/origin/main on fafd9d0 |
| 5210 | + └── ≡📙:3:main <> origin/main →:1: on fafd9d0 |
| 5211 | + └── 📙:3:main <> origin/main →:1: |
| 5212 | + "); |
| 5213 | + |
| 5214 | + Ok(()) |
| 5215 | +} |
| 5216 | + |
| 5217 | +#[test] |
| 5218 | +fn no_ws_commit_two_branches_no_target() -> anyhow::Result<()> { |
| 5219 | + let (repo, mut meta) = read_only_in_memory_scenario("ws/no-ws-ref-no-ws-commit-two-branches")?; |
| 5220 | + insta::assert_snapshot!(visualize_commit_graph_all(&repo)?, @r" |
| 5221 | + * bce0c5e (HEAD -> gitbutler/workspace, main, B, A) M2 |
| 5222 | + * 3183e43 M1 |
| 5223 | + "); |
| 5224 | + remove_target(&mut meta); |
| 5225 | + add_stack_with_segments(&mut meta, 0, "main", StackState::InWorkspace, &[]); |
| 5226 | + add_stack_with_segments(&mut meta, 1, "A", StackState::InWorkspace, &[]); |
| 5227 | + |
| 5228 | + let graph = Graph::from_head(&repo, &*meta, standard_options())?.validated()?; |
| 5229 | + insta::assert_snapshot!(graph_tree(&graph), @r" |
| 5230 | + └── 👉📕►►►:0[0]:gitbutler/workspace |
| 5231 | + ├── 📙►:2[1]:main |
| 5232 | + │ └── ►:1[2]:anon: →:3: |
| 5233 | + │ ├── ·bce0c5e (⌂|🏘|1) ►B |
| 5234 | + │ └── ·3183e43 (⌂|🏘|1) |
| 5235 | + └── 📙►:3[1]:A |
| 5236 | + └── →:1: |
| 5237 | + "); |
| 5238 | + insta::assert_snapshot!(graph_workspace(&graph.to_workspace()?), @r" |
| 5239 | + 📕🏘️⚠️:0:gitbutler/workspace <> ✓! on bce0c5e |
| 5240 | + ├── ≡📙:3:A on bce0c5e |
| 5241 | + │ └── 📙:3:A |
| 5242 | + └── ≡📙:2:main on bce0c5e |
| 5243 | + └── 📙:2:main |
| 5244 | + "); |
| 5245 | + Ok(()) |
| 5246 | +} |
| 5247 | + |
5147 | 5248 | mod edit_commit {
|
5148 | 5249 | use crate::init::{add_workspace, id_at, read_only_in_memory_scenario, standard_options};
|
5149 | 5250 | use but_graph::Graph;
|
|
0 commit comments