This commit is contained in:
Cosimo Streppone 2022-11-12 16:23:00 -05:00 committed by GitHub
commit d34d2679db
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 7 deletions

View file

@ -482,6 +482,7 @@ describe('git-auth-helper tests', () => {
) )
settings.persistCredentials = false settings.persistCredentials = false
settings.sshKey = '' settings.sshKey = ''
settings.submodules = true
const authHelper = gitAuthHelper.createAuthHelper(git, settings) const authHelper = gitAuthHelper.createAuthHelper(git, settings)
await authHelper.configureAuth() await authHelper.configureAuth()
const mockSubmoduleForeach = git.submoduleForeach as jest.Mock<any, any> const mockSubmoduleForeach = git.submoduleForeach as jest.Mock<any, any>
@ -515,6 +516,7 @@ describe('git-auth-helper tests', () => {
configureSubmoduleAuth_configuresSubmodulesWhenPersistCredentialsFalseAndSshKeySet configureSubmoduleAuth_configuresSubmodulesWhenPersistCredentialsFalseAndSshKeySet
) )
settings.persistCredentials = false settings.persistCredentials = false
settings.submodules = true
const authHelper = gitAuthHelper.createAuthHelper(git, settings) const authHelper = gitAuthHelper.createAuthHelper(git, settings)
await authHelper.configureAuth() await authHelper.configureAuth()
const mockSubmoduleForeach = git.submoduleForeach as jest.Mock<any, any> const mockSubmoduleForeach = git.submoduleForeach as jest.Mock<any, any>
@ -541,6 +543,7 @@ describe('git-auth-helper tests', () => {
configureSubmoduleAuth_configuresSubmodulesWhenPersistCredentialsTrueAndSshKeyNotSet configureSubmoduleAuth_configuresSubmodulesWhenPersistCredentialsTrueAndSshKeyNotSet
) )
settings.sshKey = '' settings.sshKey = ''
settings.submodules = true
const authHelper = gitAuthHelper.createAuthHelper(git, settings) const authHelper = gitAuthHelper.createAuthHelper(git, settings)
await authHelper.configureAuth() await authHelper.configureAuth()
const mockSubmoduleForeach = git.submoduleForeach as jest.Mock<any, any> const mockSubmoduleForeach = git.submoduleForeach as jest.Mock<any, any>
@ -580,6 +583,7 @@ describe('git-auth-helper tests', () => {
await setup( await setup(
configureSubmoduleAuth_configuresSubmodulesWhenPersistCredentialsTrueAndSshKeySet configureSubmoduleAuth_configuresSubmodulesWhenPersistCredentialsTrueAndSshKeySet
) )
settings.submodules = true
const authHelper = gitAuthHelper.createAuthHelper(git, settings) const authHelper = gitAuthHelper.createAuthHelper(git, settings)
await authHelper.configureAuth() await authHelper.configureAuth()
const mockSubmoduleForeach = git.submoduleForeach as jest.Mock<any, any> const mockSubmoduleForeach = git.submoduleForeach as jest.Mock<any, any>

6
dist/index.js vendored
View file

@ -7287,8 +7287,10 @@ class GitAuthHelper {
core.warning(`Failed to remove '${configKey}' from the git config`); core.warning(`Failed to remove '${configKey}' from the git config`);
} }
} }
const pattern = regexpHelper.escape(configKey); if (this.settings.submodules) {
yield this.git.submoduleForeach(`git config --local --name-only --get-regexp '${pattern}' && git config --local --unset-all '${configKey}' || :`, true); const pattern = regexpHelper.escape(configKey);
yield this.git.submoduleForeach(`git config --local --name-only --get-regexp '${pattern}' && git config --local --unset-all '${configKey}' || :`, true);
}
}); });
} }
} }

View file

@ -363,10 +363,12 @@ class GitAuthHelper {
} }
} }
const pattern = regexpHelper.escape(configKey) if (this.settings.submodules) {
await this.git.submoduleForeach( const pattern = regexpHelper.escape(configKey)
`git config --local --name-only --get-regexp '${pattern}' && git config --local --unset-all '${configKey}' || :`, await this.git.submoduleForeach(
true `git config --local --name-only --get-regexp '${pattern}' && git config --local --unset-all '${configKey}' || :`,
) true
)
}
} }
} }