Skip to content

Hide Create PR banner for branches whose remote was deleted - #81

Merged
danipen merged 1 commit into
mainfrom
fix-pr-banner-stale-upstream
Jul 14, 2026
Merged

Hide Create PR banner for branches whose remote was deleted#81
danipen merged 1 commit into
mainfrom
fix-pr-banner-stale-upstream

Conversation

@danipen

@danipen danipen commented Jul 14, 2026

Copy link
Copy Markdown
Owner

Problem

The Create Pull Request banner appeared for a local branch whose configured upstream no longer exists on the remote — for example a stale local master that still tracks origin/master after the remote renamed its default to main. git's porcelain keeps reporting the configured upstream (# branch.upstream origin/master) even though the remote-tracking ref is gone, so GitGrove considered the branch "published" and offered a PR that GitHub can't actually create (there is no such branch on the remote to compare from).

Seen on the Avalonia repo: on master (tracking a deleted origin/master, remote default is now main), GitGrove offered "Create Pull Request" for a dead compare.

Note: the existing default-branch check (current === defaultBranch) was working correctly and is unrelated — master genuinely isn't Avalonia's default (main is).

Fix

Treat a branch as published only when its upstream remote branch actually exists among the branch's remote refs — not merely when one is configured. This also naturally covers any branch whose remote was deleted.

The banner gate is extracted from the usePullRequests hook into a pure, unit-tested createPrBannerUrl() so every condition is covered directly.

Tests

New pr-banner.test.ts (8 tests), including the exact scenario: a stale master tracking a deleted origin/master → no banner. bun test, typecheck, and lint all green.

The "Create Pull Request" banner treated a branch as published whenever
git reported a configured upstream. But git reports the configured
upstream even when the remote-tracking ref no longer exists (e.g. a
stale local `master` still tracking `origin/master` after the remote
renamed its default to `main`). Such a branch has nothing on the remote
to open a PR from, so the banner offered a dead action.

Require the upstream remote branch to actually exist among the branch's
remote refs before offering the banner. The gate is extracted into a
pure, unit-tested createPrBannerUrl() so every condition is covered
directly rather than through the hook.
@danipen
danipen merged commit bf9fb22 into main Jul 14, 2026
9 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.

1 participant