Fix CI test failures by configuring git user in worktree clones

Shared clones created with 'git clone --shared' have independent .git
directories and don't inherit config from the source repository. This
caused 'Author identity unknown' errors when tests tried to commit in
worktree directories.

Now configure git user.name and user.email in each worktree directory
immediately after creation.
This commit is contained in:
nrslib 2026-02-04 04:28:07 +09:00
parent e7a1012050
commit 1b0a84601d
2 changed files with 16 additions and 0 deletions

View File

@ -54,6 +54,10 @@ describe('worktree branch deletion', () => {
worktreeDir = join(tmpdir(), branchSlug); worktreeDir = join(tmpdir(), branchSlug);
execFileSync('git', ['clone', '--shared', testDir, worktreeDir]); execFileSync('git', ['clone', '--shared', testDir, worktreeDir]);
// Configure git user in worktree (shared clones don't inherit config)
execFileSync('git', ['config', 'user.name', 'Test User'], { cwd: worktreeDir });
execFileSync('git', ['config', 'user.email', 'test@example.com'], { cwd: worktreeDir });
const branchName = `takt/${branchSlug}`; const branchName = `takt/${branchSlug}`;
execFileSync('git', ['checkout', '-b', branchName], { cwd: worktreeDir }); execFileSync('git', ['checkout', '-b', branchName], { cwd: worktreeDir });
@ -112,6 +116,10 @@ describe('worktree branch deletion', () => {
worktreeDir = join(tmpdir(), branchSlug); worktreeDir = join(tmpdir(), branchSlug);
execFileSync('git', ['clone', '--shared', testDir, worktreeDir]); execFileSync('git', ['clone', '--shared', testDir, worktreeDir]);
// Configure git user in worktree (shared clones don't inherit config)
execFileSync('git', ['config', 'user.name', 'Test User'], { cwd: worktreeDir });
execFileSync('git', ['config', 'user.email', 'test@example.com'], { cwd: worktreeDir });
const branchName = `takt/${branchSlug}`; const branchName = `takt/${branchSlug}`;
execFileSync('git', ['checkout', '-b', branchName], { cwd: worktreeDir }); execFileSync('git', ['checkout', '-b', branchName], { cwd: worktreeDir });

View File

@ -55,6 +55,10 @@ describe('worktree-sessions recognition', () => {
// Create shared clone // Create shared clone
execFileSync('git', ['clone', '--shared', testDir, worktreeDir]); execFileSync('git', ['clone', '--shared', testDir, worktreeDir]);
// Configure git user in worktree (shared clones don't inherit config)
execFileSync('git', ['config', 'user.name', 'Test User'], { cwd: worktreeDir });
execFileSync('git', ['config', 'user.email', 'test@example.com'], { cwd: worktreeDir });
// Create and checkout takt branch in worktree // Create and checkout takt branch in worktree
const branchName = `takt/${branchSlug}`; const branchName = `takt/${branchSlug}`;
execFileSync('git', ['checkout', '-b', branchName], { cwd: worktreeDir }); execFileSync('git', ['checkout', '-b', branchName], { cwd: worktreeDir });
@ -109,6 +113,10 @@ describe('worktree-sessions recognition', () => {
worktreeDir = join(tmpdir(), branchSlug); worktreeDir = join(tmpdir(), branchSlug);
execFileSync('git', ['clone', '--shared', testDir, worktreeDir]); execFileSync('git', ['clone', '--shared', testDir, worktreeDir]);
// Configure git user in worktree (shared clones don't inherit config)
execFileSync('git', ['config', 'user.name', 'Test User'], { cwd: worktreeDir });
execFileSync('git', ['config', 'user.email', 'test@example.com'], { cwd: worktreeDir });
const branchName = `takt/${branchSlug}`; const branchName = `takt/${branchSlug}`;
execFileSync('git', ['checkout', '-b', branchName], { cwd: worktreeDir }); execFileSync('git', ['checkout', '-b', branchName], { cwd: worktreeDir });