* perf(git): fold upstream status into git poll * fix: keep git status polling lint-clean
32 lines
936 B
TypeScript
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 })
|
|
})
|
|
})
|