Skip to content

Commit 355d02a

Browse files
committed
Fix some tests in commit_engine
1 parent 28229e6 commit 355d02a

File tree

2 files changed

+24
-36
lines changed

2 files changed

+24
-36
lines changed

crates/but-workspace/src/commit_engine/refs.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ pub fn rewrite(
3939
}
4040
}
4141
if stack.head(repo)? == old_git2 {
42-
stack.set_stack_head_without_persisting(repo, new.to_git2(), None)?;
42+
// Perhaps skip this - the head will be updated later in this call
43+
// stack.set_stack_head_without_persisting(repo, new.to_git2(), None)?;
4344
stack.tree = new
4445
.attach(repo)
4546
.object()?

crates/but-workspace/tests/workspace/commit_engine/refs_update.rs

Lines changed: 22 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -194,27 +194,13 @@ fn new_commits_to_tip_from_unborn_head() -> anyhow::Result<()> {
194194
Sha1(273aeca7ca98af0f7972af6e7859a3ae7fde497a),
195195
),
196196
references: [
197-
UpdatedReference {
198-
reference: Virtual(
199-
"s1",
200-
),
201-
old_commit_id: Sha1(2abfa5cc3c7c48b8b9eabbd10c21b88347801f15),
202-
new_commit_id: Sha1(189ac82eb44ddb97677d7d7b1859cf6f2e33a473),
203-
},
204197
UpdatedReference {
205198
reference: Virtual(
206199
"s1-b/second",
207200
),
208201
old_commit_id: Sha1(2abfa5cc3c7c48b8b9eabbd10c21b88347801f15),
209202
new_commit_id: Sha1(189ac82eb44ddb97677d7d7b1859cf6f2e33a473),
210203
},
211-
UpdatedReference {
212-
reference: Virtual(
213-
"s2",
214-
),
215-
old_commit_id: Sha1(2abfa5cc3c7c48b8b9eabbd10c21b88347801f15),
216-
new_commit_id: Sha1(189ac82eb44ddb97677d7d7b1859cf6f2e33a473),
217-
},
218204
UpdatedReference {
219205
reference: Virtual(
220206
"s2-b/second",
@@ -248,7 +234,7 @@ fn new_commits_to_tip_from_unborn_head() -> anyhow::Result<()> {
248234
write_vrbranches_to_refs(&vb, &repo)?;
249235
// It updates stack heads and stack branch heads.
250236
insta::assert_snapshot!(graph_commit_outcome(&repo, &outcome)?, @r"
251-
* 189ac82 (HEAD -> main, s2-b/second, s2, s1-b/second, s1, another-tip) fourth commit
237+
* 189ac82 (HEAD -> main, s2-b/second, s1-b/second, another-tip) fourth commit
252238
* 2abfa5c third commit
253239
* f1b87da (tag: tag-that-should-not-move, s2-b/first, s1-b/first) second commit
254240
* 0939187 (s2-b/init, s1-b/init) initial commit
@@ -310,7 +296,7 @@ fn insert_commit_into_single_stack_with_signatures() -> anyhow::Result<()> {
310296
write_vrbranches_to_refs(&vb, &repo)?;
311297
let rewritten_head_id = repo.head_id()?.detach();
312298
insta::assert_snapshot!(visualize_commit_graph(&repo, rewritten_head_id)?, @r"
313-
* 3d1262e (HEAD -> main, s1) insert 10 lines to the top
299+
* 3d1262e (HEAD -> main) insert 10 lines to the top
314300
* 3aec753 (s1-b/init, first-commit) between initial and former first
315301
* ecd6722 (tag: first-commit) init
316302
");
@@ -332,13 +318,6 @@ fn insert_commit_into_single_stack_with_signatures() -> anyhow::Result<()> {
332318
Sha1(5fdd31363b3f0987135feaa00a734ca31e1652d6),
333319
),
334320
references: [
335-
UpdatedReference {
336-
reference: Virtual(
337-
"s1",
338-
),
339-
old_commit_id: Sha1(8b9db8455554fe317ea3ab86b9a042805326b493),
340-
new_commit_id: Sha1(3d1262e63b945d97e1eaeb736b48cf4dcdb3e9cf),
341-
},
342321
UpdatedReference {
343322
reference: Git(
344323
FullName(
@@ -348,6 +327,13 @@ fn insert_commit_into_single_stack_with_signatures() -> anyhow::Result<()> {
348327
old_commit_id: Sha1(8b9db8455554fe317ea3ab86b9a042805326b493),
349328
new_commit_id: Sha1(3d1262e63b945d97e1eaeb736b48cf4dcdb3e9cf),
350329
},
330+
UpdatedReference {
331+
reference: Virtual(
332+
"",
333+
),
334+
old_commit_id: Sha1(ecd67221705b069c4f46365a46c8f2cd8a97ec19),
335+
new_commit_id: Sha1(3aec75308383b83d85a78a90308a618755a7b0f8),
336+
},
351337
UpdatedReference {
352338
reference: Virtual(
353339
"s1-b/init",
@@ -409,7 +395,7 @@ fn insert_commit_into_single_stack_with_signatures() -> anyhow::Result<()> {
409395
)?;
410396
let rewritten_head_id = repo.head_id()?;
411397
insta::assert_snapshot!(visualize_commit_graph(&repo, rewritten_head_id)?, @r"
412-
* 4b649eb (HEAD -> main, s1) insert 10 lines to the top
398+
* 4b649eb (HEAD -> main) insert 10 lines to the top
413399
* d26d789 (s1-b/init, first-commit) between initial and former first
414400
* ecd6722 (tag: first-commit) init
415401
");
@@ -470,7 +456,7 @@ fn branch_tip_below_non_merge_workspace_commit() -> anyhow::Result<()> {
470456

471457
write_vrbranches_to_refs(&vb, &repo)?;
472458
insta::assert_snapshot!(visualize_commit_graph(&repo, repo.head_id()?)?, @r"
473-
* ec84c94 (HEAD -> main, s1) insert 20 lines to the top
459+
* ec84c94 (HEAD -> main) insert 20 lines to the top
474460
* 82bb267 (s1-b/init) extend lines to 110
475461
* 4342edf (tag: first-commit) init
476462
");
@@ -576,7 +562,7 @@ fn insert_commits_into_workspace() -> anyhow::Result<()> {
576562

577563
let rewritten_head_id = repo.head_id()?;
578564
insta::assert_snapshot!(visualize_commit_graph(&repo, rewritten_head_id)?, @r"
579-
* a97960f (HEAD -> merge, s1) Merge branch 'A' into merge
565+
* a97960f (HEAD -> merge) Merge branch 'A' into merge
580566
|\
581567
| * 3538622 (A) add 10 to the beginning
582568
* | 46991ae (s1-b/init, B) add 10 more lines at end
@@ -706,7 +692,7 @@ fn merge_commit_remains_unsigned_in_remerge() -> anyhow::Result<()> {
706692
insta::assert_snapshot!(visualize_commit_graph(&repo, rewritten_head_id)?, @r"
707693
* 595a255 (HEAD -> merge) Merge branch 'A' into merge
708694
|\
709-
| * 057f154 (s1-b/top, s1, A) remove 5 lines from beginning
695+
| * 057f154 (s1-b/top, A) remove 5 lines from beginning
710696
| * eede47d add 10 to the beginning
711697
* | 16fe86e (B) add 10 to the end
712698
|/
@@ -918,7 +904,7 @@ fn commit_on_top_of_branch_in_workspace() -> anyhow::Result<()> {
918904
insta::assert_snapshot!(visualize_commit_graph(&repo, rewritten_head_id)?, @r"
919905
* 09ac476 (HEAD -> merge) Merge branch 'A' into merge
920906
|\
921-
| * 99f3a1c (s1-b/top, s1, A) remove 5 lines from beginning
907+
| * 99f3a1c (s1-b/top, A) remove 5 lines from beginning
922908
| * 7f389ed (s1-b/below-top) add 10 to the beginning
923909
* | 91ef6f6 (B) add 10 to the end
924910
|/
@@ -996,7 +982,7 @@ fn amend_on_top_of_branch_in_workspace() -> anyhow::Result<()> {
996982
insta::assert_snapshot!(visualize_commit_graph(&repo, rewritten_head_id)?, @r"
997983
* 20d9863 (HEAD -> merge) Merge branch 'A' into merge
998984
|\
999-
| * 3edfe68 (s1-b/top, s1, A) add 10 to the beginning
985+
| * 3edfe68 (s1-b/top, A) add 10 to the beginning
1000986
* | 91ef6f6 (B) add 10 to the end
1001987
|/
1002988
* ff045ef (main) init
@@ -1083,12 +1069,13 @@ mod utils {
10831069
repo: &gix::Repository,
10841070
) -> anyhow::Result<()> {
10851071
for stack in vbranches.branches.values() {
1086-
repo.reference(
1087-
format!("refs/heads/{}", stack.name),
1088-
stack.head(repo)?.to_gix(),
1089-
PreviousValue::Any,
1090-
"create stack head for visualization",
1091-
)?;
1072+
// makes no sense to crate this?
1073+
// repo.reference(
1074+
// format!("refs/heads/{}", stack.name),
1075+
// stack.head(repo)?.to_gix(),
1076+
// PreviousValue::Any,
1077+
// "create stack head for visualization",
1078+
// )?;
10921079
for branch in &stack.heads {
10931080
let commit_id = branch.head_oid(repo)?.to_gix();
10941081
repo.reference(

0 commit comments

Comments
 (0)