Fix local branch rebasing after land#120
Open
roxchkplusony wants to merge 2 commits intomodular:mainfrom
Open
Conversation
Author
|
NOTE: This also seems to fix #117 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This change updates
stack-pr landso that when the current branch contains the stack being landed, the local branch is rebased onto the updated stack tip rather than being rebased independently ontoorigin/main.As a result, the local branch now reuses the same rewritten commits as the remaining PR branches after landing, and then rebases any additional local commits on top as usual.
This PR also includes a follow-up fix so that the rewritten stack tip is resolved to a stable commit hash before local stack branches are cleaned up.
Problem
Previously,
stack-pr landwould:origin/<target>.That preserved equivalent content, but it did not guarantee that the local branch would be based on the same commit chain as the PR branches. In practice, the local branch could diverge from the rewritten stack and end up with different commit identities.
A follow-up regression also remained when PRs still existed above the landed one: the command tracked the rewritten remaining stack tip by local branch name, then deleted the local stack branches before rebasing the current branch. In real usage this could fail with
fatal: invalid upstream '<branch>'.Fix
This change adjusts
command_landto:If there are no remaining PRs in the stack, the current branch is still rebased onto the refreshed
origin/<target>.Tests
Added regression coverage for the
landcommand flow:Validation
Validated locally with:
python3 -m py_compile src/stack_pr/cli.py tests/test_land.pypytest tests/test_land.pypytestThe pytest runs were executed in the repo's pyenv virtualenv (
Python 3.9.25).Pytest emits two existing config warnings about unknown
asyncio_default_fixture_loop_scopeandasyncio_modeoptions, but all tests pass.Pull Request opened by Augment Code with guidance from the PR author