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>2021-11-01 11:43:18 -0500
committerGitHub <noreply@github.com>2021-11-01 11:43:18 -0500
commit0fc042ca35b9ee6d4c6dc650662d40f189018a49 (patch)
treeb357edb1a8f6da9760e4dc15a179d0db27d9bcaa /src/git-auth-helper.ts
parentd7a4963ed25cda3df63783c22befd89dcbc4508d (diff)
set insteadOf url for org-id (#621)v2.4.0
Diffstat (limited to 'src/git-auth-helper.ts')
-rw-r--r--src/git-auth-helper.ts25
1 files changed, 17 insertions, 8 deletions
diff --git a/src/git-auth-helper.ts b/src/git-auth-helper.ts
index af400ab..233b3e6 100644
--- a/src/git-auth-helper.ts
+++ b/src/git-auth-helper.ts
@@ -37,7 +37,7 @@ class GitAuthHelper {
private readonly tokenConfigValue: string
private readonly tokenPlaceholderConfigValue: string
private readonly insteadOfKey: string
- private readonly insteadOfValue: string
+ private readonly insteadOfValues: string[] = []
private sshCommand = ''
private sshKeyPath = ''
private sshKnownHostsPath = ''
@@ -45,7 +45,7 @@ class GitAuthHelper {
constructor(
gitCommandManager: IGitCommandManager,
- gitSourceSettings?: IGitSourceSettings
+ gitSourceSettings: IGitSourceSettings | undefined
) {
this.git = gitCommandManager
this.settings = gitSourceSettings || (({} as unknown) as IGitSourceSettings)
@@ -63,7 +63,12 @@ class GitAuthHelper {
// Instead of SSH URL
this.insteadOfKey = `url.${serverUrl.origin}/.insteadOf` // "origin" is SCHEME://HOSTNAME[:PORT]
- this.insteadOfValue = `git@${serverUrl.hostname}:`
+ this.insteadOfValues.push(`git@${serverUrl.hostname}:`)
+ if (this.settings.workflowOrganizationId) {
+ this.insteadOfValues.push(
+ `org-${this.settings.workflowOrganizationId}@github.com:`
+ )
+ }
}
async configureAuth(): Promise<void> {
@@ -118,7 +123,9 @@ class GitAuthHelper {
// Configure HTTPS instead of SSH
await this.git.tryConfigUnset(this.insteadOfKey, true)
if (!this.settings.sshKey) {
- await this.git.config(this.insteadOfKey, this.insteadOfValue, true)
+ for (const insteadOfValue of this.insteadOfValues) {
+ await this.git.config(this.insteadOfKey, insteadOfValue, true, true)
+ }
}
} catch (err) {
// Unset in case somehow written to the real global config
@@ -159,10 +166,12 @@ class GitAuthHelper {
)
} else {
// Configure HTTPS instead of SSH
- await this.git.submoduleForeach(
- `git config --local '${this.insteadOfKey}' '${this.insteadOfValue}'`,
- this.settings.nestedSubmodules
- )
+ for (const insteadOfValue of this.insteadOfValues) {
+ await this.git.submoduleForeach(
+ `git config --local --add '${this.insteadOfKey}' '${insteadOfValue}'`,
+ this.settings.nestedSubmodules
+ )
+ }
}
}
}