Files
orca/src/relay/git-handler-utils.test.ts
T
Neil f0705af998 perf(git): fold upstream status into git poll (#1828)
* perf(git): fold upstream status into git poll

* fix: keep git status polling lint-clean
2026-05-14 01:37:36 -07:00

32 lines
936 B
TypeScript

import { describe, expect, it } from 'vitest'
import { parseStatusOutput } from './git-status-output-parser'
describe('parseStatusOutput', () => {
it('parses upstream ahead/behind from porcelain v2 branch headers', () => {
const result = parseStatusOutput(
[
'# branch.oid abcdef1234567890',
'# branch.head feature/prompts',
'# branch.upstream origin/feature/prompts',
'# branch.ab +2 -3',
''
].join('\n')
)
expect(result.upstreamStatus).toEqual({
hasUpstream: true,
upstreamName: 'origin/feature/prompts',
ahead: 2,
behind: 3
})
})
it('reports no upstream when porcelain v2 omits branch.upstream', () => {
const result = parseStatusOutput(
['# branch.oid abcdef1234567890', '# branch.head feature/prompts', ''].join('\n')
)
expect(result.upstreamStatus).toEqual({ hasUpstream: false, ahead: 0, behind: 0 })
})
})