Files
orca/src/shared/git-status-upstream-ref.test.ts
T
Brennan Benson de64337c26 fix(worktree-watcher): refresh status after external pushes (#12361)
* fix(worktree-watcher): surface external push -u through the git-common watch

An external-shell 'git push -u' writes only the common .git/config (plus
refs/remotes/<remote>/<branch>), both invisible to the git-common event
filter, so the Checks panel stayed on 'No upstream configured' until the
renderer safety poll. Classify the common config and remote-tracking refs
as status-tier signals, poll config alongside the other primary-checkout
metadata files, and keep FETCH_HEAD/reflog/ref-lock churn ignored.

* fix(worktree-watcher): refresh after subsequent pushes
2026-08-05 11:26:13 -07:00

29 lines
1.2 KiB
TypeScript

import { describe, expect, it } from 'vitest'
import { isSafeGitRefName, isSafeGitStatusUpstreamRef } from './git-status-upstream-ref'
describe('git status upstream refs', () => {
it('accepts exact remote and custom upstream namespaces', () => {
expect(isSafeGitStatusUpstreamRef('refs/remotes/team/fork/feature/nested')).toBe(true)
expect(isSafeGitStatusUpstreamRef('refs/custom/origin/main')).toBe(true)
expect(isSafeGitStatusUpstreamRef('refs/tracking/main')).toBe(true)
expect(isSafeGitStatusUpstreamRef('refs/tracked-main')).toBe(true)
})
it('recognizes local branch refs without accepting them for dynamic status polling', () => {
expect(isSafeGitRefName('refs/heads/feature/base')).toBe(true)
expect(isSafeGitStatusUpstreamRef('refs/heads/feature/base')).toBe(false)
expect(isSafeGitStatusUpstreamRef('refs/worktree/feature/base')).toBe(false)
})
it.each([
'refs/heads/main',
'/refs/remotes/origin/main',
'refs/remotes/origin/../main',
'refs/remotes/origin/main.lock',
'refs/remotes/origin/feature\\escape',
'refs/remotes/origin/@{upstream}'
])('rejects unsafe or non-remote ref %s', (ref) => {
expect(isSafeGitStatusUpstreamRef(ref)).toBe(false)
})
})