diff --git a/__test__/git-auth-helper.test.ts b/__test__/git-auth-helper.test.ts index 7633704..a14bacf 100644 --- a/__test__/git-auth-helper.test.ts +++ b/__test__/git-auth-helper.test.ts @@ -482,6 +482,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 @@ -515,6 +516,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 @@ -541,6 +543,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 @@ -580,6 +583,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 2b7dd09..6646058 100644 --- a/dist/index.js +++ b/dist/index.js @@ -424,10 +424,12 @@ class GitAuthHelper { core.warning(`Failed to remove '${configKey}' from the git config`); } } - const pattern = regexpHelper.escape(configKey); - yield this.git.submoduleForeach( - // wrap the pipeline in quotes to make sure it's handled properly by submoduleForeach, rather than just the first part of the pipeline - `sh -c "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( + // wrap the pipeline in quotes to make sure it's handled properly by submoduleForeach, rather than just the first part of the pipeline + `sh -c "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 126e8e5..eafa009 100644 --- a/src/git-auth-helper.ts +++ b/src/git-auth-helper.ts @@ -364,11 +364,13 @@ class GitAuthHelper { } } - const pattern = regexpHelper.escape(configKey) - await this.git.submoduleForeach( - // wrap the pipeline in quotes to make sure it's handled properly by submoduleForeach, rather than just the first part of the pipeline - `sh -c "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( + // wrap the pipeline in quotes to make sure it's handled properly by submoduleForeach, rather than just the first part of the pipeline + `sh -c "git config --local --name-only --get-regexp '${pattern}' && git config --local --unset-all '${configKey}' || :"`, + true + ) + } } }