This commit is contained in:
2026-09-28 16:52:20 +02:00
parent f6ed92be1c
commit 1380eee989
+7 -1
View File
@@ -6,12 +6,18 @@
import { run } from './exec.js'; import { run } from './exec.js';
export function gitAuthEnv(token, baseEnv = process.env) { export function gitAuthEnv(token, baseEnv = process.env) {
// Gitea's git-over-HTTP backend (unlike its REST API) does not accept the
// "Authorization: token <t>" scheme — it wants HTTP Basic auth, username
// arbitrary, password/token as the credential. "oauth2" as the username
// is an arbitrary placeholder (matches the convention other git hosts
// use for token auth) — Gitea only checks the token in the password slot.
const basic = Buffer.from(`oauth2:${token}`).toString('base64');
return { return {
...baseEnv, ...baseEnv,
GIT_TERMINAL_PROMPT: '0', GIT_TERMINAL_PROMPT: '0',
GIT_CONFIG_COUNT: '1', GIT_CONFIG_COUNT: '1',
GIT_CONFIG_KEY_0: 'http.extraHeader', GIT_CONFIG_KEY_0: 'http.extraHeader',
GIT_CONFIG_VALUE_0: `Authorization: token ${token}`, GIT_CONFIG_VALUE_0: `Authorization: Basic ${basic}`,
}; };
} }