repositories / will

will

owned by bugabinga

test: make worktree tests independent of ambient git config

6b5fff2745989de232aac443b9b2eb95ae3a47e0

Oliver Jan Krylow <oliver@bugabinga.net> ·

SSH signature · not checked

Browse filesCompare with HEAD

CI boxes carry no global git identity and may enforce commit signing;
both broke the worktree int tests (pass locally only by accident of
Oliver's global config). Pass -c user.* and disable gpgsign explicitly.

Changed files (1)

+16 / −6 text lines

Diff layout

src/agent/runtime.int.test.ts

Modified

+16 / −6 text lines

2222const exec = promisify(execFile)
24/** committer identity and signing must not depend on the machine's global git config (CI has none) */
25const GIT_IDENTITY = [
26 '-c',
27 'user.name=t',
28 '-c',
29 'user.email=t@t',
30 '-c',
31 'commit.gpgsign=false',
32]
2434test('worktree: clone, ff-only when clean, preserved when dirty or ahead', async () => {
2535 const dir = await mkdtemp(join(tmpdir(), 'wt-'))
2636 const remote = join(dir, 'origin.git')
@@ -30,7 +40,7 @@ worktree: clone, ff-only when clean, preserved when dirty or ahead
3040 await exec('git', ['clone', remote, seed])
3141 await writeFile(join(seed, 'a.txt'), 'one\n')
3242 await exec('git', ['add', '.'], { cwd: seed })
33 await exec('git', ['commit', '-m', 'one', '--author', 't <t@t>'], { cwd: seed })
43 await exec('git', [...GIT_IDENTITY, 'commit', '-m', 'one', '--author', 't <t@t>'], { cwd: seed })
3444 await exec('git', ['push', 'origin', 'trunk'], { cwd: seed })
3646 const s1 = await syncWorktree(work, remote, 'trunk')
@@ -39,7 +49,7 @@ worktree: clone, ff-only when clean, preserved when dirty or ahead
4050 // advance remote; clean worktree fast-forwards
4151 await writeFile(join(seed, 'a.txt'), 'two\n')
42 await exec('git', ['commit', '-am', 'two', '--author', 't <t@t>'], { cwd: seed })
52 await exec('git', [...GIT_IDENTITY, 'commit', '-am', 'two', '--author', 't <t@t>'], { cwd: seed })
4353 await exec('git', ['push', 'origin', 'trunk'], { cwd: seed })
4454 const s2 = await syncWorktree(work, remote, 'trunk')
4555 assert.equal(s2.fastForwarded, true)
@@ -48,7 +58,7 @@ worktree: clone, ff-only when clean, preserved when dirty or ahead
4858 // dirty worktree: preserved, no ff, reported
4959 await writeFile(join(work, 'b.txt'), 'local\n')
5060 await writeFile(join(seed, 'a.txt'), 'three\n')
51 await exec('git', ['commit', '-am', 'three', '--author', 't <t@t>'], { cwd: seed })
61 await exec('git', [...GIT_IDENTITY, 'commit', '-am', 'three', '--author', 't <t@t>'], { cwd: seed })
5262 await exec('git', ['push', 'origin', 'trunk'], { cwd: seed })
5363 const s3 = await syncWorktree(work, remote, 'trunk')
5464 assert.equal(s3.dirty, true)
@@ -57,7 +67,7 @@ worktree: clone, ff-only when clean, preserved when dirty or ahead
5868 // ahead commits: diverged, preserved
5969 await exec('git', ['add', '.'], { cwd: work })
60 await exec('git', ['commit', '-m', 'local', '--author', 't <t@t>'], { cwd: work })
70 await exec('git', [...GIT_IDENTITY, 'commit', '-m', 'local', '--author', 't <t@t>'], { cwd: work })
6171 const s4 = await syncWorktree(work, remote, 'trunk')
6272 assert.equal(s4.diverged, true)
6373})
@@ -71,7 +81,7 @@ readWorktreeState: fresh head and dirty flag without fetch or merge
7181 await exec('git', ['clone', remote, seed])
7282 await writeFile(join(seed, 'a.txt'), 'one\n')
7383 await exec('git', ['add', '.'], { cwd: seed })
74 await exec('git', ['commit', '-m', 'one', '--author', 't <t@t>'], { cwd: seed })
84 await exec('git', [...GIT_IDENTITY, 'commit', '-m', 'one', '--author', 't <t@t>'], { cwd: seed })
7585 await exec('git', ['push', 'origin', 'trunk'], { cwd: seed })
7686 await exec('git', ['clone', '--quiet', remote, work])
@@ -83,7 +93,7 @@ readWorktreeState: fresh head and dirty flag without fetch or merge
8393 // a local commit moves HEAD; the read reports it without merging origin
8494 await writeFile(join(work, 'b.txt'), 'local\n')
8595 await exec('git', ['add', '.'], { cwd: work })
86 await exec('git', ['commit', '-m', 'local', '--author', 't <t@t>'], { cwd: work })
96 await exec('git', [...GIT_IDENTITY, 'commit', '-m', 'local', '--author', 't <t@t>'], { cwd: work })
8797 const s2 = await readWorktreeState(work)
8898 assert.equal(s2.head, (await head()).stdout.trim())
8999 assert.notEqual(s2.head, s1.head)