MCPcopy Index your code
hub / github.com/anomalyco/opencode / configureGit

Function configureGit

packages/opencode/src/cli/cmd/github.handler.ts:1013–1032  ·  view source on GitHub ↗
(appToken: string)

Source from the content-addressed store, hash-verified

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

Callers 1

github.handler.tsFile · 0.70

Calls 4

gitStatusFunction · 0.85
gitRunFunction · 0.85
logMethod · 0.45
fromMethod · 0.45

Tested by

no test coverage detected