Read-only mirror — the public repositories of the Forgejo instance, refreshed every 10 minutes. The live instance (fg.dieschoenewolke.de) is reachable only over the VPN; clone here with https://git.dieschoenewolke.de/git/<owner>/<repo>.git.
summaryrefslogtreecommitdiff
path: root/src/git-auth-helper.ts
diff options
context:
space:
mode:
authoreric sciple <ericsciple@users.noreply.github.com>2020-03-12 11:42:38 -0400
committerGitHub <noreply@github.com>2020-03-12 11:42:38 -0400
commit6f1b729011b34bc28608462b6293df85180aba9c (patch)
tree21ab78013bc7cc88344c3cb9feaaa42213b20407 /src/git-auth-helper.ts
parent1b406b27feed694fb3a05a638c92124514baa6ea (diff)
persist core.sshCommand for submodules (#184)
* persist core.sshCommand for submodules * update verbiage; add comments * fail when submodules or ssh-key and fallback to REST API
Diffstat (limited to 'src/git-auth-helper.ts')
-rw-r--r--src/git-auth-helper.ts23
1 files changed, 15 insertions, 8 deletions
diff --git a/src/git-auth-helper.ts b/src/git-auth-helper.ts
index 7418c7c..06e8912 100644
--- a/src/git-auth-helper.ts
+++ b/src/git-auth-helper.ts
@@ -37,6 +37,7 @@ class GitAuthHelper {
private readonly tokenPlaceholderConfigValue: string
private readonly insteadOfKey: string = `url.https://${HOSTNAME}/.insteadOf`
private readonly insteadOfValue: string = `git@${HOSTNAME}:`
+ private sshCommand = ''
private sshKeyPath = ''
private sshKnownHostsPath = ''
private temporaryHomePath = ''
@@ -144,8 +145,14 @@ class GitAuthHelper {
this.replaceTokenPlaceholder(configPath)
}
- // Configure HTTPS instead of SSH
- if (!this.settings.sshKey) {
+ if (this.settings.sshKey) {
+ // Configure core.sshCommand
+ await this.git.submoduleForeach(
+ `git config --local '${SSH_COMMAND_KEY}' '${this.sshCommand}'`,
+ this.settings.nestedSubmodules
+ )
+ } else {
+ // Configure HTTPS instead of SSH
await this.git.submoduleForeach(
`git config --local '${this.insteadOfKey}' '${this.insteadOfValue}'`,
this.settings.nestedSubmodules
@@ -218,21 +225,21 @@ class GitAuthHelper {
// Configure GIT_SSH_COMMAND
const sshPath = await io.which('ssh', true)
- let sshCommand = `"${sshPath}" -i "$RUNNER_TEMP/${path.basename(
+ this.sshCommand = `"${sshPath}" -i "$RUNNER_TEMP/${path.basename(
this.sshKeyPath
)}"`
if (this.settings.sshStrict) {
- sshCommand += ' -o StrictHostKeyChecking=yes -o CheckHostIP=no'
+ this.sshCommand += ' -o StrictHostKeyChecking=yes -o CheckHostIP=no'
}
- sshCommand += ` -o "UserKnownHostsFile=$RUNNER_TEMP/${path.basename(
+ this.sshCommand += ` -o "UserKnownHostsFile=$RUNNER_TEMP/${path.basename(
this.sshKnownHostsPath
)}"`
- core.info(`Temporarily overriding GIT_SSH_COMMAND=${sshCommand}`)
- this.git.setEnvironmentVariable('GIT_SSH_COMMAND', sshCommand)
+ core.info(`Temporarily overriding GIT_SSH_COMMAND=${this.sshCommand}`)
+ this.git.setEnvironmentVariable('GIT_SSH_COMMAND', this.sshCommand)
// Configure core.sshCommand
if (this.settings.persistCredentials) {
- await this.git.config(SSH_COMMAND_KEY, sshCommand)
+ await this.git.config(SSH_COMMAND_KEY, this.sshCommand)
}
}