()
| 402 | } |
| 403 | |
| 404 | function 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 | |
| 422 | function captureWorkingDirectory(ctx) { |
| 423 | if (!workspacePath && ctx?.session?.workingDirectory) { |
no outgoing calls
no test coverage detected