MCPcopy
hub / github.com/github/awesome-copilot / readBranchFromGit

Function readBranchFromGit

extensions/site-studio/extension.mjs:404–420  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

402}
403
404function readBranchFromGit() {
405 if (process.env.COPILOT_WORKSPACE_BRANCH) {
406 return process.env.COPILOT_WORKSPACE_BRANCH;
407 }
408 const candidates = [workspacePath, process.cwd(), REPO_ROOT_FALLBACK].filter((value, index, all) => value && all.indexOf(value) === index);
409 for (const cwd of candidates) {
410 try {
411 const branch = execSync("git --no-pager rev-parse --abbrev-ref HEAD", { cwd, stdio: ["ignore", "pipe", "ignore"], timeout: 2000, maxBuffer: 1024 * 1024 })
412 .toString()
413 .trim();
414 if (branch) {
415 return branch;
416 }
417 } catch {}
418 }
419 return "unknown";
420}
421
422function captureWorkingDirectory(ctx) {
423 if (!workspacePath && ctx?.session?.workingDirectory) {

Callers 2

createInitialStateFunction · 0.85
extension.mjsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected