Skip to content

Fix release test by isolating git operations from global/system configurations#43

Merged
silverwind merged 7 commits intomasterfrom
copilot/fix-release-test-assertion
Jan 30, 2026
Merged

Fix release test by isolating git operations from global/system configurations#43
silverwind merged 7 commits intomasterfrom
copilot/fix-release-test-assertion

Conversation

Copy link
Contributor

Copilot AI commented Jan 30, 2026

The release test fails locally with exit code 128: git tag -f -F - 1.0.1 when the environment has git signing configurations like tag.forcesignannotated=true enabled globally. Without a configured GPG key in the test environment, git tag creation fails.

Changes

  • Created getIsolatedGitEnv() helper function that isolates tests from all git configurations using environment variables:

    • HOME - Points to a temporary directory to prevent reading ~/.gitconfig
    • GIT_CONFIG_GLOBAL - Points to a non-existent file in the isolated HOME
    • GIT_CONFIG_NOSYSTEM=1 - Prevents reading system-wide git config
  • Updated initGitRepo() and all test git commands to use the isolated environment

// Create isolated git environment that ignores global and system configs
function getIsolatedGitEnv(tmpDir: string) {
  const isolatedHome = join(tmpDir, ".home");
  return {
    HOME: isolatedHome,
    GIT_CONFIG_GLOBAL: join(isolatedHome, ".gitconfig"),
    GIT_CONFIG_NOSYSTEM: "1",
  };
}

async function initGitRepo(tmpDir: string): Promise<void> {
  const env = getIsolatedGitEnv(tmpDir);
  await mkdir(env.HOME, {recursive: true});
  await spawnEnhanced("git", ["init"], {cwd: tmpDir, env: {...process.env, ...env}});
  await spawnEnhanced("git", ["config", "--local", "user.email", "test@test.com"], {cwd: tmpDir, env: {...process.env, ...env}});
  await spawnEnhanced("git", ["config", "--local", "user.name", "Test User"], {cwd: tmpDir, env: {...process.env, ...env}});
}

Benefits

  • Tests now work regardless of global, system, or user-level git configurations
  • No need to manually override specific config values like commit.gpgsign, tag.gpgsign, or tag.forcesignannotated
  • More robust and predictable test behavior across different environments
  • Production code remains unchanged and respects user's git configuration including signing preferences

Testing

  • ✅ All 20 tests pass
  • ✅ Release test specifically verified with tag.forcesignannotated=true configuration
  • ✅ Tests are completely isolated from host git configuration
Original prompt

The release test is failing locally with "AssertionError: expected '[master 0db574b] 1.0.1\n 1 file chang…' to contain 'Failed to create release'", please fix


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: silverwind <115237+silverwind@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix assertion error in release test Fix release test failing on git tag creation when tag.gpgsign enabled Jan 30, 2026
Copilot AI requested a review from silverwind January 30, 2026 12:43
@silverwind
Copy link
Owner

@copilot it's still failing locally:

 FAIL  index.test.ts > release
AssertionError: expected '[master a5f06a6] 1.0.1\n 1 file chang…' to contain 'Failed to create release'

- Expected
+ Received

- Failed to create release
+ [master a5f06a6] 1.0.1
+  1 file changed, 1 insertion(+), 1 deletion(-)
+ SubprocessError: Command failed with exit code 128: git tag -f -F - 1.0.1
+     at he (file:///Users/silverwind/git/versions/dist/index.js:2:2482)
+     at pe (file:///Users/silverwind/git/versions/dist/index.js:2:2161)
+     at process.processTicksAndRejections (node:internal/process/task_queues:103:5)
+     at async P (file:///Users/silverwind/git/versions/dist/index.js:5:75)
+     at async gt (file:///Users/silverwind/git/versions/dist/index.js:50:9)

 ❯ index.test.ts:537:26
    535|       expect(await readFile(join(tmpDir, "testfile.txt"), "utf8")).toEqual("version 1.0.1");
    536|       // Should contain error about failed release creation
    537|       expect(err.output).toContain("Failed to create release");
       |                          ^
    538|       // Should show either 401 Unauthorized or 403 Forbidden
    539|       expect(err.output).toMatch(/401|403/);

Copilot AI and others added 4 commits January 30, 2026 12:50
Co-authored-by: silverwind <115237+silverwind@users.noreply.github.com>
…g config

Co-authored-by: silverwind <115237+silverwind@users.noreply.github.com>
Co-authored-by: silverwind <115237+silverwind@users.noreply.github.com>
Co-authored-by: silverwind <115237+silverwind@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jan 30, 2026

@copilot it's still failing locally:

...

Fixed in 919692f. The issue was caused by your global git configuration with tag.forcesignannotated=true. Tests now run in a completely isolated git environment (using HOME, GIT_CONFIG_GLOBAL, and GIT_CONFIG_NOSYSTEM env vars) that ignores all global, system, and user-level configurations. Production code unchanged - it will still respect your signing preferences when you use the tool normally.

@silverwind silverwind marked this pull request as ready for review January 30, 2026 13:01
Copilot AI changed the title Fix release test failing on git tag creation when tag.gpgsign enabled Fix release test by isolating git operations from global/system configurations Jan 30, 2026
@silverwind silverwind merged commit 05018bd into master Jan 30, 2026
18 checks passed
@silverwind silverwind deleted the copilot/fix-release-test-assertion branch January 30, 2026 13:01
Copilot AI requested a review from silverwind January 30, 2026 13:01
Copilot stopped work on behalf of silverwind due to an error January 30, 2026 13:01
silverwind added a commit that referenced this pull request Jan 30, 2026
* Fix release test failing on git tag creation when tag.gpgsign enabled (#43) (Copilot)
* Add --release/-R flag to create GitHub/Gitea releases via API (#42) (Copilot)
* Add prerelease command with --preid option for all version commands (#41) (Copilot)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants