deploy: use reliable HTTPS transport for Gitea sync
This commit is contained in:
12
deploy/git-credential-tea.ts
Normal file
12
deploy/git-credential-tea.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
// Repository-local HTTPS credential helper. Git consumes stdout; never log it.
|
||||
import { join } from 'node:path';
|
||||
if (process.argv[2] !== 'get') process.exit(0);
|
||||
const fields = Object.fromEntries((await Bun.stdin.text()).trim().split('\n').map(line => {
|
||||
const index = line.indexOf('='); return [line.slice(0, index), line.slice(index + 1)];
|
||||
}));
|
||||
if (fields.protocol !== 'https' || fields.host !== 'git.ayau.me' || fields.path !== 'syntaxbullet/minabot.git') process.exit(0);
|
||||
const base = process.env.XDG_CONFIG_HOME || join(process.env.HOME!, 'Library', 'Application Support');
|
||||
const config = Bun.YAML.parse(await Bun.file(join(base, 'tea', 'config.yml')).text()) as { logins?: { name: string; url: string; user: string; token: string }[] };
|
||||
const login = config.logins?.find(login => login.name === 'ayau' && login.url.replace(/\/$/, '') === 'https://git.ayau.me');
|
||||
if (!login?.token || !login.user || /[\r\n]/.test(login.token + login.user)) process.exit(1);
|
||||
process.stdout.write(`username=${login.user}\npassword=${login.token}\n\n`);
|
||||
Reference in New Issue
Block a user