@@ -1044,11 +1044,12 @@ func TestRebase_BranchDiverged_NoFF(t *testing.T) {
10441044
10451045func TestRebase_SkipsMergedBranchesNotExistingLocally (t * testing.T ) {
10461046 // Simulates a stack where b1 is merged and its branch was auto-deleted
1047- // from the remote, so it doesn't exist locally.
1047+ // from the remote, so it doesn't exist locally. The stored Head SHA is
1048+ // used as ontoOldBase for the next branch's --onto rebase.
10481049 s := stack.Stack {
10491050 Trunk : stack.BranchRef {Branch : "main" },
10501051 Branches : []stack.BranchRef {
1051- {Branch : "b1" , PullRequest : & stack.PullRequestRef {Number : 42 , Merged : true }},
1052+ {Branch : "b1" , Head : "b1-stored-head-sha" , PullRequest : & stack.PullRequestRef {Number : 42 , Merged : true }},
10521053 {Branch : "b2" },
10531054 },
10541055 }
@@ -1095,7 +1096,10 @@ func TestRebase_SkipsMergedBranchesNotExistingLocally(t *testing.T) {
10951096 assert .NoError (t , err )
10961097 assert .Contains (t , output , "Skipping b1" )
10971098
1098- // Only b2 should be rebased
1099+ // Only b2 should be rebased, and the rebase should use b1's stored
1100+ // Head SHA as oldBase so `git rebase --onto` receives valid arguments.
10991101 require .Len (t , rebaseCalls , 1 )
11001102 assert .Equal (t , "b2" , rebaseCalls [0 ].branch )
1103+ assert .Equal (t , "main" , rebaseCalls [0 ].newBase )
1104+ assert .Equal (t , "b1-stored-head-sha" , rebaseCalls [0 ].oldBase )
11011105}
0 commit comments