Skip to content

Commit

Permalink
GH#354 Disabled auth submodules config when related setting is false
Browse files Browse the repository at this point in the history
This should help with actions#354.
The problem is that I have no idea whether such auth submodules configuration
is required even when settings.submodules is false.
  • Loading branch information
cosimo committed Jan 13, 2021
1 parent 5a4ac90 commit 66145e6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
4 changes: 4 additions & 0 deletions __test__/git-auth-helper.test.ts
Expand Up @@ -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<any, any>
Expand Down Expand Up @@ -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<any, any>
Expand All @@ -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<any, any>
Expand Down Expand Up @@ -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<any, any>
Expand Down
12 changes: 7 additions & 5 deletions src/git-auth-helper.ts
Expand Up @@ -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
)
}
}
}

0 comments on commit 66145e6

Please sign in to comment.