From c9518fb4085560fb070febbe36aa2b70cba22e0b Mon Sep 17 00:00:00 2001 From: eric sciple Date: Fri, 17 Oct 2025 00:18:04 +0000 Subject: [PATCH] . --- dist/index.js | 20 ++++++++++++++------ src/git-auth-helper.ts | 25 ++++++++++++++++++------- 2 files changed, 32 insertions(+), 13 deletions(-) diff --git a/dist/index.js b/dist/index.js index 3d2b9ca..5725651 100644 --- a/dist/index.js +++ b/dist/index.js @@ -483,21 +483,25 @@ class GitAuthHelper { // Remove HTTP extra header yield this.removeGitConfig(this.tokenConfigKey); yield this.removeSubmoduleGitConfig(this.tokenConfigKey); + // Collect credentials config paths that need to be removed + const credentialsPaths = new Set(); // Remove includeIf entries that point to git-credentials-*.config files - yield this.removeIncludeIfCredentials(); + const mainCredentialsPaths = yield this.removeIncludeIfCredentials(); + mainCredentialsPaths.forEach(path => credentialsPaths.add(path)); // Remove submodule includeIf entries that point to git-credentials-*.config files const submoduleConfigPaths = yield this.git.getSubmoduleConfigPaths(true); for (const configPath of submoduleConfigPaths) { - yield this.removeIncludeIfCredentials(configPath); + const submoduleCredentialsPaths = yield this.removeIncludeIfCredentials(configPath); + submoduleCredentialsPaths.forEach(path => credentialsPaths.add(path)); } - // Remove credentials config file - if (this.credentialsConfigPath) { + // Remove credentials config files + for (const credentialsPath of credentialsPaths) { try { - yield io.rmRF(this.credentialsConfigPath); + yield io.rmRF(credentialsPath); } catch (err) { core.debug(`${(_a = err === null || err === void 0 ? void 0 : err.message) !== null && _a !== void 0 ? _a : err}`); - core.warning(`Failed to remove credentials config '${this.credentialsConfigPath}'`); + core.warning(`Failed to remove credentials config '${credentialsPath}'`); } } }); @@ -530,9 +534,11 @@ class GitAuthHelper { /** * Removes includeIf entries that point to git-credentials-*.config files. * @param configPath Optional path to a specific git config file to operate on + * @returns Array of unique credentials config file paths that were found and removed */ removeIncludeIfCredentials(configPath) { return __awaiter(this, void 0, void 0, function* () { + const credentialsPaths = new Set(); try { // Get all includeIf.gitdir keys const keys = yield this.git.tryGetConfigKeys('^includeIf\\.gitdir:', false, configPath); @@ -543,6 +549,7 @@ class GitAuthHelper { // Remove only values that match git-credentials-.config pattern for (const value of values) { if (this.testCredentialsConfigPath(value)) { + credentialsPaths.add(value); yield this.git.tryConfigUnsetValue(key, value, false, configPath); } } @@ -558,6 +565,7 @@ class GitAuthHelper { core.debug(`Error during includeIf cleanup: ${err}`); } } + return Array.from(credentialsPaths); }); } /** diff --git a/src/git-auth-helper.ts b/src/git-auth-helper.ts index 245962e..f7c8d8a 100644 --- a/src/git-auth-helper.ts +++ b/src/git-auth-helper.ts @@ -455,23 +455,28 @@ class GitAuthHelper { await this.removeGitConfig(this.tokenConfigKey) await this.removeSubmoduleGitConfig(this.tokenConfigKey) + // Collect credentials config paths that need to be removed + const credentialsPaths = new Set() + // Remove includeIf entries that point to git-credentials-*.config files - await this.removeIncludeIfCredentials() + const mainCredentialsPaths = await this.removeIncludeIfCredentials() + mainCredentialsPaths.forEach(path => credentialsPaths.add(path)) // Remove submodule includeIf entries that point to git-credentials-*.config files const submoduleConfigPaths = await this.git.getSubmoduleConfigPaths(true) for (const configPath of submoduleConfigPaths) { - await this.removeIncludeIfCredentials(configPath) + const submoduleCredentialsPaths = await this.removeIncludeIfCredentials(configPath) + submoduleCredentialsPaths.forEach(path => credentialsPaths.add(path)) } - // Remove credentials config file - if (this.credentialsConfigPath) { + // Remove credentials config files + for (const credentialsPath of credentialsPaths) { try { - await io.rmRF(this.credentialsConfigPath) + await io.rmRF(credentialsPath) } catch (err) { core.debug(`${(err as any)?.message ?? err}`) core.warning( - `Failed to remove credentials config '${this.credentialsConfigPath}'` + `Failed to remove credentials config '${credentialsPath}'` ) } } @@ -507,8 +512,11 @@ class GitAuthHelper { /** * Removes includeIf entries that point to git-credentials-*.config files. * @param configPath Optional path to a specific git config file to operate on + * @returns Array of unique credentials config file paths that were found and removed */ - private async removeIncludeIfCredentials(configPath?: string): Promise { + private async removeIncludeIfCredentials(configPath?: string): Promise { + const credentialsPaths = new Set() + try { // Get all includeIf.gitdir keys const keys = await this.git.tryGetConfigKeys('^includeIf\\.gitdir:', false, configPath) @@ -520,6 +528,7 @@ class GitAuthHelper { // Remove only values that match git-credentials-.config pattern for (const value of values) { if (this.testCredentialsConfigPath(value)) { + credentialsPaths.add(value) await this.git.tryConfigUnsetValue(key, value, false, configPath) } } @@ -533,6 +542,8 @@ class GitAuthHelper { core.debug(`Error during includeIf cleanup: ${err}`) } } + + return Array.from(credentialsPaths) } /**