Skip to content

fix(git-review): key the render's PR cache by the branch's own name - #791

Merged
sirmalloc merged 1 commit into
sirmalloc:mainfrom
effectustasi:fix/pr-cache-shadowed-branch
Nov 5, 2026
Merged

sirmalloc merged 1 commit into
sirmalloc:mainfrom
effectustasi:fix/pr-cache-shadowed-branch

Conversation

@effectustasi

Copy link
Copy Markdown
Contributor

#774 made getCurrentBranch read symbolic-ref HEAD and strip refs/heads/, because symbolic-ref --short HEAD prints heads/<branch> when a tag has the same name as the branch. The render path's own lookup from #639, getCacheRefFromContext, still runs symbolic-ref --short HEAD through the cached runGit.

So with a tag named like the branch, the render reads the cache file for branch:heads/feature/x while the refresh child writes the one for branch:feature/x. The widget never finds the data, and the child never releases the lock it was given (its expected lock path is the other file), so after the lock goes stale another gh/glab refresh runs and writes the same unread file again.

Real CLI, branch feature/x with tag feature/x, fake gh returning PR #42, three renders 2s apart:

  • before: (no PR), (no PR), (no PR), plus an orphaned .lock
  • after: (no PR) (cold cache), then PR #42 OPEN Add x twice; one cache file, no leftover lock

getCacheRefFromContext now runs symbolic-ref HEAD and strips the prefix with the same helper getCurrentBranch uses (toBranchName). Git Branch already runs that command, so the cached runGit answers both.

Added a test where a tag shadows the branch; it fails on main (render and refresh child use different lock paths) and passes with this change. Two existing runGit stubs were updated for the new command string.

With a tag named like the current branch, `git symbolic-ref --short HEAD`
prints "heads/<branch>". The refresh child keys the PR cache by the full
ref with "refs/heads/" stripped since sirmalloc#774, but the render's lookup
through the cached runGit (sirmalloc#639) still used --short. The two then hash
to different cache files: the child writes the PR to one, Git PR and Git
CI Status read the other, and the widgets show "(no PR)" on every render
while a refresh runs again each time its lock goes stale. The child also
never releases the lock it was handed, since that lock belongs to the
other cache file.

The render's lookup now reads `symbolic-ref HEAD` and strips the prefix
the same way, which is also the command Git Branch already runs, so the
cached runGit answers both.
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