(appToken: string)
| 1011 | } |
| 1012 | |
| 1013 | async function configureGit(appToken: string) { |
| 1014 | // Do not change git config when running locally |
| 1015 | if (isMock) return |
| 1016 | |
| 1017 | console.log("Configuring git...") |
| 1018 | const config = "http.https://github.com/.extraheader" |
| 1019 | // actions/checkout@v6 no longer stores credentials in .git/config, |
| 1020 | // so this may not exist - use nothrow() to handle gracefully |
| 1021 | const ret = await gitStatus(["config", "--local", "--get", config]) |
| 1022 | if (ret.exitCode === 0) { |
| 1023 | gitConfig = ret.stdout.toString().trim() |
| 1024 | await gitRun(["config", "--local", "--unset-all", config]) |
| 1025 | } |
| 1026 | |
| 1027 | const newCredentials = Buffer.from(`x-access-token:${appToken}`, "utf8").toString("base64") |
| 1028 | |
| 1029 | await gitRun(["config", "--local", config, `AUTHORIZATION: basic ${newCredentials}`]) |
| 1030 | await gitRun(["config", "--global", "user.name", AGENT_USERNAME]) |
| 1031 | await gitRun(["config", "--global", "user.email", `${AGENT_USERNAME}@users.noreply.github.com`]) |
| 1032 | } |
| 1033 | |
| 1034 | async function restoreGitConfig() { |
| 1035 | if (gitConfig === undefined) return |
no test coverage detected