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
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/git-auth-helper.ts23
-rw-r--r--src/git-source-provider.ts10
2 files changed, 25 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)
}
}
diff --git a/src/git-source-provider.ts b/src/git-source-provider.ts
index 7ce9fb7..4bce702 100644
--- a/src/git-source-provider.ts
+++ b/src/git-source-provider.ts
@@ -57,6 +57,16 @@ export async function getSource(settings: IGitSourceSettings): Promise<void> {
core.info(
`To create a local Git repository instead, add Git ${gitCommandManager.MinimumGitVersion} or higher to the PATH`
)
+ if (settings.submodules) {
+ throw new Error(
+ `Input 'submodules' not supported when falling back to download using the GitHub REST API. To create a local Git repository instead, add Git ${gitCommandManager.MinimumGitVersion} or higher to the PATH.`
+ )
+ } else if (settings.sshKey) {
+ throw new Error(
+ `Input 'ssh-key' not supported when falling back to download using the GitHub REST API. To create a local Git repository instead, add Git ${gitCommandManager.MinimumGitVersion} or higher to the PATH.`
+ )
+ }
+
await githubApiHelper.downloadRepository(
settings.authToken,
settings.repositoryOwner,