Rebuild workspace commit when upstream target is already up-to-date#13761
Open
mtsgrd wants to merge 1 commit into
Open
Rebuild workspace commit when upstream target is already up-to-date#13761mtsgrd wants to merge 1 commit into
mtsgrd wants to merge 1 commit into
Conversation
When `default_target.sha` in TOML already matches origin/master (e.g. after `bootstrap_default_target_if_missing` writes the remote tip directly), `integrate_upstream` returned `UpToDate` and skipped rebuilding the workspace commit. This left the workspace commit parented on an older base while the UI showed commits behind. Now we always rebuild the workspace commit in the `UpToDate` path so the worktree reflects the current target even when the metadata was already advanced.
2cc8ce1 to
01270f2
Compare
Contributor
Author
|
@Caleb-T-Owens could you take a quick look? |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a workspace desynchronization bug where integrate_upstream returned “up-to-date” and skipped rebuilding the GitButler workspace commit, leaving it parented on an older base even when default_target.sha had already been advanced to the remote tip.
Changes:
- Rebuild the workspace commit even when upstream integration reports “up-to-date”.
- Add a regression test covering the stale-workspace-commit scenario.
- Add a new
but-workspacescenario fixture for a merge-commit-head case.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
crates/gitbutler-branch-actions/src/upstream_integration.rs |
Rebuilds the workspace commit on the “up-to-date” integration path. |
crates/gitbutler-branch-actions/tests/branch-actions/virtual_branches/apply_virtual_branch.rs |
Adds a regression test reproducing the stale workspace commit base issue. |
crates/but-workspace/tests/fixtures/scenario/merge-commit-head-already-integrated.sh |
Adds a new repository-shape fixture for workspace/upstream integration testing. |
| crate::integration::update_workspace_commit_with_vb_state( | ||
| &virtual_branches_state, | ||
| ctx, | ||
| false, |
| // `bootstrap_default_target_if_missing` advanced `default_target.sha` | ||
| // without rebuilding the workspace commit). Rebuild it so the | ||
| // worktree reflects the current target. | ||
| let virtual_branches_state = VirtualBranchesHandle::new(ctx.project_data_dir()); |
Comment on lines
+1059
to
+1063
| let base_after = gitbutler_branch_actions::base::get_base_branch_data(ctx).unwrap(); | ||
| assert_eq!( | ||
| base_after.behind, 0, | ||
| "workspace should be rebuilt on current target" | ||
| ); |
Comment on lines
+1
to
+6
| #!/usr/bin/env bash | ||
|
|
||
| source "${BASH_SOURCE[0]%/*}/shared.sh" | ||
|
|
||
| git init --initial-branch=master | ||
| echo "Branch whose head is a merge commit that merged master into feature - already integrated upstream" >.git/description |
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.
When
default_target.shain TOML already matches origin/master (e.g.after
bootstrap_default_target_if_missingwrites the remote tipdirectly),
integrate_upstreamreturnedUpToDateand skippedrebuilding the workspace commit. This left the workspace commit
parented on an older base while the UI showed commits behind.
Now we always rebuild the workspace commit in the
UpToDatepath sothe worktree reflects the current target even when the metadata was
already advanced.