mirror of
https://github.com/stablyai/orca.git
synced 2026-10-19 00:03:20 +00:00
* fix(git): reduce queries and preserve data across execution hosts * fix(ci): exercise pinned Git and serialize mobile dependency entrypoints * fix(relay): preserve fresh diff retries after hung shared reads * test(git): wait for fetch barrier before canceling preparation * fix(i18n): describe index-preserving discard in every locale * fix(git): retain clone diagnostics and allow WSL policy startup * test(git): refresh default-base and branch-safety fixtures
69 lines
2.1 KiB
TypeScript
69 lines
2.1 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import {
|
|
parseGitRevListAheadBehindCounts,
|
|
parseGitRevListFirstParentOid,
|
|
parseGitRevListCommitAndFirstParentOid
|
|
} from './git-rev-list-output'
|
|
|
|
describe('parseGitRevListAheadBehindCounts', () => {
|
|
it('parses counts surrounded by mixed whitespace', () => {
|
|
expect(parseGitRevListAheadBehindCounts(' 12\t3\r\n')).toEqual({
|
|
status: 'ok',
|
|
ahead: 12,
|
|
behind: 3
|
|
})
|
|
})
|
|
|
|
it('rejects missing or extra fields', () => {
|
|
expect(parseGitRevListAheadBehindCounts('1\n')).toEqual({
|
|
status: 'unexpected-field-count'
|
|
})
|
|
expect(parseGitRevListAheadBehindCounts('1 2 3\n')).toEqual({
|
|
status: 'unexpected-field-count'
|
|
})
|
|
})
|
|
|
|
it('rejects unparseable counts', () => {
|
|
expect(parseGitRevListAheadBehindCounts('1 nope\n')).toEqual({
|
|
status: 'unparseable-counts'
|
|
})
|
|
expect(parseGitRevListAheadBehindCounts('-1 2\n')).toEqual({
|
|
status: 'unparseable-counts'
|
|
})
|
|
})
|
|
})
|
|
|
|
describe('parseGitRevListFirstParentOid', () => {
|
|
it('returns the first parent from rev-list parent output', () => {
|
|
expect(parseGitRevListFirstParentOid('commit-oid parent-oid second-parent\n')).toBe(
|
|
'parent-oid'
|
|
)
|
|
})
|
|
|
|
it('returns null for a root commit', () => {
|
|
expect(parseGitRevListFirstParentOid('commit-oid\n')).toBeNull()
|
|
})
|
|
})
|
|
|
|
describe('parseGitRevListCommitAndFirstParentOid', () => {
|
|
it.each([40, 64])('reads SHA-%i commit metadata without retaining later parents', (length) => {
|
|
expect(
|
|
parseGitRevListCommitAndFirstParentOid(
|
|
`${'a'.repeat(length)} ${'b'.repeat(length)} ${'c'.repeat(length)}\n`
|
|
)
|
|
).toEqual({
|
|
commitOid: 'a'.repeat(length),
|
|
parentOid: 'b'.repeat(length)
|
|
})
|
|
})
|
|
|
|
it('preserves a root commit and rejects empty or malformed answers', () => {
|
|
expect(parseGitRevListCommitAndFirstParentOid(`${'a'.repeat(40)}\n`)).toEqual({
|
|
commitOid: 'a'.repeat(40),
|
|
parentOid: null
|
|
})
|
|
expect(() => parseGitRevListCommitAndFirstParentOid('')).toThrow('Unexpected')
|
|
expect(() => parseGitRevListCommitAndFirstParentOid('HEAD\n')).toThrow('Unexpected')
|
|
})
|
|
})
|