Skip to content

Add another but-graph test to pin existing behavior#13222

Merged
Byron merged 1 commit intogitbutlerapp:masterfrom
Byron:fix-missing-target
Apr 13, 2026
Merged

Add another but-graph test to pin existing behavior#13222
Byron merged 1 commit intogitbutlerapp:masterfrom
Byron:fix-missing-target

Conversation

@Byron
Copy link
Copy Markdown
Collaborator

@Byron Byron commented Apr 8, 2026

This PR ultimately was hunting a phantom in #13222, which apparently needs more finesse to lure out in a test.

But this hunt at least led to an additional test which I think covers something worth pinning down: the local tracking branch to the remote tracking branch that is the target isn't special, and it's valid for it to disappear if there is competition.

Old

Summary

  • ensure but-graph always creates an exact target segment for configured workspace target refs when the graph would otherwise only contain the local tracking segment
  • keep workspace target resolution stable in ambiguous remote/local shapes, including cases where the remote ref itself is absent but the local branch still tracks it
  • update the existing ambiguous-with-remotes snapshots and add a focused regression for the missing target-segment case

Tasks

  • refackiew

Root Cause

but-graph could end up with only a local tracking segment like main <> origin/main and no exact refs/remotes/origin/main segment. The workspace projection expects the configured target ref to exist as its own segment, so target resolution could fail or become shape-dependent after post-processing.

Impact

This normalizes the graph shape for configured workspace targets so downstream workspace logic can rely on the exact target segment existing when possible.

Validation

  • cargo fmt --check --all
  • cargo test -p but-graph

Notes

  • This draft PR was created by Codex.
  • Byron still needs to review the change before it should be merged.

@vercel
Copy link
Copy Markdown

vercel bot commented Apr 8, 2026

@Byron is attempting to deploy a commit to the GitButler Team on Vercel.

A member of the Team first needs to authorize it.

@Byron Byron force-pushed the fix-missing-target branch from a334936 to 9fbbb21 Compare April 13, 2026 04:34
@Byron Byron changed the title [codex] Ensure but-graph keeps exact target segments Add another but-graph test to pin existing behavior Apr 13, 2026
@Byron Byron marked this pull request as ready for review April 13, 2026 05:05
Copilot AI review requested due to automatic review settings April 13, 2026 05:05
…'t get its own segment.

This is fine, as the only thing that matters is a segment for the target branch.

Of course, there could be code that tries to find the local tracking branch
of the remote tracking branch that is the target branch, but for now I think
it's ok to assume it doesn't exist or that it doesn't lead to issues.

It should always be possible to have a utility function that uses sibling
links if present, but falls back to brute-force search through commits and
their assigned references.
@Byron Byron force-pushed the fix-missing-target branch from 9fbbb21 to b0e7039 Compare April 13, 2026 05:06
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a regression test in but-graph to pin behavior around workspace target resolution when multiple refs compete on the same base commit (including presence of refs/remotes/origin/HEAD), ensuring the exact target segment for refs/remotes/origin/main remains present/empty even when an inactive “unapplied” stack exists.

Changes:

  • Add a new workspace-focused graph test covering “shared target base + inactive unapplied branch” behavior.
  • Add a new git fixture scenario that creates competing local refs plus refs/remotes/origin/HEAD alongside origin/main.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
crates/but-graph/tests/graph/init/with_workspace.rs Adds a new regression test + snapshots asserting target-segment and workspace target_ref resolution behavior.
crates/but-graph/tests/fixtures/scenarios.sh Adds a new fixture scenario to reproduce the ref-competition shape used by the new test.

Comment thread crates/but-graph/tests/graph/init/with_workspace.rs
Comment thread crates/but-graph/tests/graph/init/with_workspace.rs
@Byron Byron merged commit 1bb761b into gitbutlerapp:master Apr 13, 2026
34 of 35 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants