Repository navigation
Report a gone upstream from Status() as IsUpstreamGone [minor] - #218
Merged
Merged
Conversation
git prints branch.upstream but no branch.ab when the upstream ref no longer exists, which left Ahead and Behind at 0 and made a branch with unpushed commits look in sync. GitStatus.IsUpstreamGone now reports that state. Fixes #177 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015ZJZ6UqCuPy8kj9xX6SHjv
|
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.



Fixes #177
What was wrong
Porcelain v2 prints
# branch.upstream origin/featbut leaves out# branch.abwhen the upstream ref no longer exists, for example after the remote branch was deleted or when it was never fetched.GitStatusParserleftAhead/Behindat their default of0. A branch with unpushed commits therefore looked in sync, and a caller could decide it was safe to throw away.Change
GitStatus.IsUpstreamGone. It istruewhenbranch.upstreamis present withoutbranch.ab, which is the stategit status -sbshows as[gone].Ahead/Behinddocs now say both are0while the upstream is gone, and that this does not mean the branch is in sync.Ahead/Behindint?, so existing callers keep compiling. The change adds public API, hence[minor].Tests
ReportsAGoneUpstreamWhenTheAheadBehindHeaderIsMissingcoversbranch.upstreamwith nobranch.ab. Two guards check that a present upstream and no upstream both report not-gone.GitRemoteSyncTests.StatusReportsAnUpstreamDeletedOnTheRemoteAsGoneAsync): the test pushesfeatwith upstream to a bare remote, makes one more commit, runsgit push origin --delete feat, and then assertsIsUpstreamGone.dotnet format --verify-no-changesis clean on the touched files.🤖 Generated with Claude Code
https://claude.ai/code/session_015ZJZ6UqCuPy8kj9xX6SHjv
Generated by Claude Code