mirror of
https://code.forgejo.org/actions/checkout.git
synced 2026-07-04 18:46:11 +00:00
Pin GIT_CONFIG_GLOBAL to the temp config during global auth setup
configureTempGlobalConfig isolates global git config by overriding HOME to a temporary directory. But GIT_CONFIG_GLOBAL takes precedence over HOME when git locates the global config file, so when a workflow already has GIT_CONFIG_GLOBAL set in the environment, 'git config --global' writes land in that file instead of the temporary config. replaceTokenPlaceholder then reads the temporary config, cannot find the placeholder, and fails with 'Unable to replace auth placeholder'. Set GIT_CONFIG_GLOBAL to the temporary config alongside the HOME override so global config operations always target the temp file regardless of any inherited value, and unset it again in removeGlobalConfig. Assisted-By: Claude Opus 4.8
This commit is contained in:
parent
b9e0990d21
commit
2d76d21b2e
3 changed files with 34 additions and 2 deletions
7
dist/index.js
vendored
7
dist/index.js
vendored
|
|
@ -35109,6 +35109,10 @@ class GitAuthHelper {
|
|||
// Override HOME
|
||||
info(`Temporarily overriding HOME='${this.temporaryHomePath}' before making global git config changes`);
|
||||
this.git.setEnvironmentVariable('HOME', this.temporaryHomePath);
|
||||
// GIT_CONFIG_GLOBAL takes precedence over HOME when locating the global
|
||||
// config file. Pin it to the temporary config so an inherited
|
||||
// GIT_CONFIG_GLOBAL cannot redirect our global git config writes elsewhere.
|
||||
this.git.setEnvironmentVariable('GIT_CONFIG_GLOBAL', newGitConfigPath);
|
||||
return newGitConfigPath;
|
||||
}
|
||||
async configureGlobalAuth() {
|
||||
|
|
@ -35183,8 +35187,9 @@ class GitAuthHelper {
|
|||
}
|
||||
async removeGlobalConfig() {
|
||||
if (this.temporaryHomePath?.length > 0) {
|
||||
core_debug(`Unsetting HOME override`);
|
||||
core_debug(`Unsetting HOME and GIT_CONFIG_GLOBAL overrides`);
|
||||
this.git.removeEnvironmentVariable('HOME');
|
||||
this.git.removeEnvironmentVariable('GIT_CONFIG_GLOBAL');
|
||||
await rmRF(this.temporaryHomePath);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue