diff --git a/__test__/git-auth-helper.test.ts b/__test__/git-auth-helper.test.ts index 2b4830cc8..75db18b83 100644 --- a/__test__/git-auth-helper.test.ts +++ b/__test__/git-auth-helper.test.ts @@ -450,6 +450,7 @@ describe('git-auth-helper tests', () => { ) settings.persistCredentials = false settings.sshKey = '' + settings.submodules = true const authHelper = gitAuthHelper.createAuthHelper(git, settings) await authHelper.configureAuth() const mockSubmoduleForeach = git.submoduleForeach as jest.Mock @@ -483,6 +484,7 @@ describe('git-auth-helper tests', () => { configureSubmoduleAuth_configuresSubmodulesWhenPersistCredentialsFalseAndSshKeySet ) settings.persistCredentials = false + settings.submodules = true const authHelper = gitAuthHelper.createAuthHelper(git, settings) await authHelper.configureAuth() const mockSubmoduleForeach = git.submoduleForeach as jest.Mock @@ -509,6 +511,7 @@ describe('git-auth-helper tests', () => { configureSubmoduleAuth_configuresSubmodulesWhenPersistCredentialsTrueAndSshKeyNotSet ) settings.sshKey = '' + settings.submodules = true const authHelper = gitAuthHelper.createAuthHelper(git, settings) await authHelper.configureAuth() const mockSubmoduleForeach = git.submoduleForeach as jest.Mock @@ -543,6 +546,7 @@ describe('git-auth-helper tests', () => { await setup( configureSubmoduleAuth_configuresSubmodulesWhenPersistCredentialsTrueAndSshKeySet ) + settings.submodules = true const authHelper = gitAuthHelper.createAuthHelper(git, settings) await authHelper.configureAuth() const mockSubmoduleForeach = git.submoduleForeach as jest.Mock diff --git a/dist/index.js b/dist/index.js index e765cc2c0..7d7042785 100644 --- a/dist/index.js +++ b/dist/index.js @@ -5652,8 +5652,10 @@ class GitAuthHelper { core.warning(`Failed to remove '${configKey}' from the git config`); } } - const pattern = regexpHelper.escape(configKey); - yield this.git.submoduleForeach(`git config --local --name-only --get-regexp '${pattern}' && git config --local --unset-all '${configKey}' || :`, true); + if (this.settings.submodules) { + const pattern = regexpHelper.escape(configKey); + yield this.git.submoduleForeach(`git config --local --name-only --get-regexp '${pattern}' && git config --local --unset-all '${configKey}' || :`, true); + } }); } } diff --git a/src/git-auth-helper.ts b/src/git-auth-helper.ts index 291d83bc2..7d620fc8d 100644 --- a/src/git-auth-helper.ts +++ b/src/git-auth-helper.ts @@ -341,10 +341,12 @@ class GitAuthHelper { } } - const pattern = regexpHelper.escape(configKey) - await this.git.submoduleForeach( - `git config --local --name-only --get-regexp '${pattern}' && git config --local --unset-all '${configKey}' || :`, - true - ) + if (this.settings.submodules) { + const pattern = regexpHelper.escape(configKey) + await this.git.submoduleForeach( + `git config --local --name-only --get-regexp '${pattern}' && git config --local --unset-all '${configKey}' || :`, + true + ) + } } }