Skip to content

show a warning icon for local branches whose upstream was deleted#259

Open
tsanko wants to merge 1 commit into
DetachHead:masterfrom
tsanko:orphaned-branch-warning-icon
Open

show a warning icon for local branches whose upstream was deleted#259
tsanko wants to merge 1 commit into
DetachHead:masterfrom
tsanko:orphaned-branch-warning-icon

Conversation

@tsanko

@tsanko tsanko commented Jun 26, 2026

Copy link
Copy Markdown

What

Adds a warning icon (and tooltip note) in the branches tree for local branches whose configured upstream has been deleted on the remote — git's gone state, e.g. after fetch --prune removes the stale remote-tracking ref.

Why

Orphaned branches were previously indistinguishable from healthy ones in the branches tree, so there was no signal that a branch's upstream is gone and the branch is a cleanup candidate.

How

  • Such branches keep their branch.<name>.merge/remote config but have no resolved GitBranchTrackInfo, so they can't be detected from tracking info. They're found by parsing the raw git config (GitConfig.parseUpstreamGoneBranches) and checking whether the configured upstream is still present among the known remote branches.
  • The result is plumbed from the backend repo info (GitRepoInfo.upstreamGoneBranches) through the RPC DTO (GitRepositoryStateDto.upstreamGoneBranches) into the shared GitRepositoryState, so the frontend renderer can pick the warning icon.
  • current/favorite states still take priority over the warning; tags and refs that can't track an upstream are never marked gone.
  • Adds a tooltip note ("Upstream branch was deleted") in the branches dashboard tree.

Tests

  • GitOrphanedBranchIconTest — unit coverage for icon selection priority and isUpstreamGone.
  • GitOrphanedBranchWidgetTest — end-to-end test exercising the full pipeline (git config → repo info → DTO → shared state → renderer) by pushing a branch, deleting it on the remote, pruning, and asserting the warning icon.

When a local branch tracks a remote branch that has since been deleted
(git's `gone` state, e.g. after `fetch --prune` removes the stale
remote-tracking ref), nothing in the branches tree signalled that the
branch is now orphaned. This surfaces it with a warning icon and a
tooltip note so the branch can be noticed and cleaned up.

Such branches keep their `branch.<name>.merge`/`remote` config but have
no resolved GitBranchTrackInfo, so they can't be detected from tracking
info. They are found by parsing the raw git config
(GitConfig.parseUpstreamGoneBranches) and checking whether the
configured upstream is still present among the known remote branches.

The result is plumbed from the backend repo info through the RPC DTO
into the shared GitRepositoryState (upstreamGoneBranches) so the
frontend renderer can pick the warning icon, with current/favorite
states still taking priority over it. Tags and refs that can't track an
upstream are never marked gone.
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.

2 participants