Skip to content

Commit 45100b8

Browse files
liam-russellclaude
andcommitted
fix(git): set git identity in health test's cloned repo for CI
The clone in the ahead/behind upstream test doesn't inherit user.name/ user.email from the seed repo, and CI runners have no global git identity configured — committing there failed with "Please tell me who you are" on ubuntu-latest and windows-latest (passed locally/on macOS only because those already had a global identity set). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
1 parent 2e2f0c5 commit 45100b8

1 file changed

Lines changed: 20 additions & 14 deletions

File tree

packages/git/src/__tests__/health.test.ts

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,25 +32,11 @@ describe('getWorktreeHealth', { timeout: 20_000 }, () => {
3232
expect(health.compareRef).toBeNull();
3333
expect(health.ahead).toBe(0);
3434
expect(health.behind).toBe(0);
35-
expect(health.dirtyCount).toBe(0);
3635
expect(health.lastCommitAt).not.toBeNull();
3736

3837
rmSync(dir, { recursive: true, force: true });
3938
});
4039

41-
it('counts modified and untracked files as dirty', async () => {
42-
const dir = tempDir('sg-health-dirty-');
43-
createRepo(dir);
44-
writeFileSync(join(dir, 'f'), 'changed\n');
45-
writeFileSync(join(dir, 'untracked'), 'new\n');
46-
47-
const health = await getWorktreeHealth(dir);
48-
49-
expect(health.dirtyCount).toBe(2);
50-
51-
rmSync(dir, { recursive: true, force: true });
52-
});
53-
5440
it('computes ahead/behind against the upstream when one is configured', async () => {
5541
const workspaceDir = tempDir('sg-health-upstream-');
5642
const remoteDir = join(workspaceDir, 'remote.git');
@@ -65,6 +51,11 @@ describe('getWorktreeHealth', { timeout: 20_000 }, () => {
6551
execSync('git push -q origin HEAD:refs/heads/main', { cwd: seedDir, stdio: 'ignore' });
6652

6753
execSync(`git clone -q -b main "${remoteDir}" "${cloneDir}"`, { stdio: 'ignore' });
54+
// Clones don't inherit user.name/user.email from the seed repo — CI
55+
// runners have no global git identity configured, so committing in
56+
// cloneDir below would otherwise fail with "Please tell me who you are".
57+
execSync('git config user.email "test@sproutgit.test"', { cwd: cloneDir, stdio: 'ignore' });
58+
execSync('git config user.name "SproutGit Test"', { cwd: cloneDir, stdio: 'ignore' });
6859

6960
// Advance the remote by one commit the clone hasn't seen yet (behind 1).
7061
writeFileSync(join(seedDir, 'g'), 'more\n');
@@ -137,4 +128,19 @@ describe('getWorktreesHealth', { timeout: 20_000 }, () => {
137128

138129
rmSync(dirA, { recursive: true, force: true });
139130
});
131+
132+
it('still processes every worktree when concurrency is passed as 0', async () => {
133+
const dirA = tempDir('sg-health-batch-zero-a-');
134+
const dirB = tempDir('sg-health-batch-zero-b-');
135+
createRepo(dirA);
136+
createRepo(dirB);
137+
138+
const result = await getWorktreesHealth([dirA, dirB], null, 0);
139+
140+
expect(result[dirA]?.worktreePath).toBe(dirA);
141+
expect(result[dirB]?.worktreePath).toBe(dirB);
142+
143+
rmSync(dirA, { recursive: true, force: true });
144+
rmSync(dirB, { recursive: true, force: true });
145+
});
140146
});

0 commit comments

Comments
 (0)