Skip to content

Commit

Permalink
test(repo sync): navigation history for unsubmitted branches
Browse files Browse the repository at this point in the history
Add a test for how merge history propagation behaves
for upstack branches that are unsubmitted.

Suppose I have `feat1 -> feat2`:

- feat1 is ready and I submit a CR
- feat2 is not yet ready for review, so it is unsubmitted
- while I'm still working on feat2, feat1 gets approved and I merge it
- I then submit feat2

Right now--by accident--it works so that feat2 receives the history:
it will show feat1 as its merged downstack even though feat1 was merged
by the time feat2 was restacked on main and submitted.

My intuition is that this should NOT be supported,
but it's also coming mostly for "free".

I'm opening up this PR and test case to discuss this behavior
with anyone who cares.
  • Loading branch information
abhinav committed Dec 21, 2024
1 parent 8f3612b commit 27e1114
Showing 1 changed file with 71 additions and 0 deletions.
71 changes: 71 additions & 0 deletions testdata/script/repo_sync_unsubmitted_upstack_history.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Merge history propagation when a branch is submitted and merged,
# while its upstacks are still unsubmitted.

as 'Test <[email protected]>'
at '2024-12-21T12:24:48Z'

# set up
cd repo
git init
git commit --allow-empty -m 'Initial commit'
gs repo init

# set up a fake GitHub remote
shamhub init
shamhub new origin alice/example.git
shamhub register alice
git push origin main

env SHAMHUB_USERNAME=alice
gs auth login

# set up main -> feat1 -> feat2
git add feat1.txt
gs branch create feat1 -m 'Add feature 1'
git add feat2.txt
gs branch create feat2 -m 'Add feature 2'

# Submit and merge feat1
gs bottom
gs bs --fill
stderr 'Created #1'
shamhub merge alice/example 1
gs rs
gs sr

# Submit feat2
gs bco feat2
gs ss --fill
stderr 'Created #2'

gs ls
cmp stderr $WORK/golden/ls-after.txt

shamhub dump comments
cmp stdout $WORK/golden/final-comments.txt

-- repo/feat1.txt --
feat 1
-- repo/feat2.txt --
feat 2
-- golden/ls-after.txt --
┏━■ feat2 (#2) ◀
main
-- golden/final-comments.txt --
- change: 1
body: |
This change is part of the following stack:

- #1 ◀

<sub>Change managed by [git-spice](https://abhinav.github.io/git-spice/).</sub>
<!-- gs:navigation comment -->
- change: 2
body: |
This change is part of the following stack:

- #1
- #2 ◀

<sub>Change managed by [git-spice](https://abhinav.github.io/git-spice/).</sub>
<!-- gs:navigation comment -->

0 comments on commit 27e1114

Please sign in to comment.