This was an update of which I cannot remember what it did but it was surely something that I needed so let's commit it. YOLO
CI / check (push) Waiting to run

This commit is contained in:
2026-09-22 16:38:00 +02:00
parent dbb7e40c6c
commit 5112d3de94
13 changed files with 172 additions and 55 deletions
+19 -1
View File
@@ -5,7 +5,25 @@ import { afterEach, describe, expect, it } from 'vitest'
import { simpleGit } from 'simple-git'
import { readFile } from 'node:fs/promises'
import { existsSync } from 'node:fs'
import { classify, discard, load, stage } from '../src/main/git-service'
import { classify, discard, load, parseAhead, stage } from '../src/main/git-service'
describe('parseAhead', () => {
it('reads the ahead count from the porcelain header', () => {
expect(parseAhead('main...origin/main [ahead 3]')).toEqual({ ahead: 3, canPush: true })
expect(parseAhead('main...origin/main [ahead 1, behind 2]')).toEqual({ ahead: 1, canPush: true })
})
it('reports nothing to push on a branch in sync', () => {
expect(parseAhead('main...origin/main')).toEqual({ ahead: 0, canPush: false })
expect(parseAhead('main...origin/main [behind 2]')).toEqual({ ahead: 0, canPush: false })
})
it('treats a branch without an upstream as pushable, count unknown', () => {
expect(parseAhead('feature/x')).toEqual({ ahead: 0, canPush: true })
})
it('reports nothing to push on an empty repo or a detached HEAD', () => {
expect(parseAhead('No commits yet on main')).toEqual({ ahead: 0, canPush: false })
expect(parseAhead('HEAD (no branch)')).toEqual({ ahead: 0, canPush: false })
})
})
describe('classify', () => {
it('reads the index code as staged, working code as unstaged', () => {