Infra: write gitea git-credentials line with the deployment's own scheme
This commit is contained in:
@@ -31,9 +31,11 @@ async function writeGiteaCredentials(file: string, gitea: GiteaAccount,
|
|||||||
env: Record<string, string | undefined>): Promise<void> {
|
env: Record<string, string | undefined>): Promise<void> {
|
||||||
const token = env[gitea.tokenEnv] ?? ''
|
const token = env[gitea.tokenEnv] ?? ''
|
||||||
if (!token) throw new SetupError('giteaTokenMissing', { name: gitea.tokenEnv })
|
if (!token) throw new SetupError('giteaTokenMissing', { name: gitea.tokenEnv })
|
||||||
const host = new URL(gitea.url).host
|
const origin = new URL(gitea.url).origin
|
||||||
|
const scheme = origin.slice(0, origin.indexOf('://'))
|
||||||
|
const host = origin.slice(origin.indexOf('://') + 3)
|
||||||
const temporary = `${file}.${process.pid}.tmp`
|
const temporary = `${file}.${process.pid}.tmp`
|
||||||
await writeFile(temporary, `https://${encodeURIComponent(gitea.login)}:${encodeURIComponent(token)}@${host}\n`, { mode: 0o600 })
|
await writeFile(temporary, `${scheme}://${encodeURIComponent(gitea.login)}:${encodeURIComponent(token)}@${host}\n`, { mode: 0o600 })
|
||||||
await rename(temporary, file)
|
await rename(temporary, file)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user