{"record":{"id":"5790574556537cec","repo":"thedotmack/claude-mem","slug":"not-in-a-git-repository-run-this-from-a-checked-o","errorCode":null,"errorMessage":"Not in a git repository. Run this from a checked-out repo.","messagePattern":"Not in a git repository\\. Run this from a checked-out repo\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/pr-babysit-status.ts","lineNumber":131,"sourceCode":"    const detail = result.stderr || result.stdout || `exit code ${result.exitCode}`;\n    throw new Error(`gh ${args.join(' ')} failed: ${detail}`);\n  }\n  return result.stdout;\n}\n\nfunction parseJson<T>(raw: string, label: string): T {\n  try {\n    return JSON.parse(raw) as T;\n  } catch (error) {\n    const message = error instanceof Error ? error.message : String(error);\n    throw new Error(`Could not parse ${label} JSON: ${message}`);\n  }\n}\n\nfunction checkPrerequisites() {\n  const git = runCommand(['git', 'rev-parse', '--is-inside-work-tree']);\n  if (git.exitCode !== 0 || git.stdout.trim() !== 'true') {\n    throw new Error('Not in a git repository. Run this from a checked-out repo.');\n  }\n\n  const ghVersion = runCommand(['gh', '--version']);\n  if (ghVersion.exitCode !== 0) {\n    throw new Error('GitHub CLI is not available. Install gh and try again.');\n  }\n\n  const auth = runCommand(['gh', 'auth', 'status']);\n  if (auth.exitCode !== 0) {\n    throw new Error(`GitHub CLI is not authenticated. Run \"gh auth login\".\\n${auth.stderr || auth.stdout}`.trim());\n  }\n}\n\nfunction targetArgs(prArg?: string): string[] {\n  return prArg ? [prArg] : [];\n}\n\nfunction fetchPr(prArg?: string): PullRequest {","sourceCodeStart":113,"sourceCodeEnd":149,"githubUrl":"https://github.com/thedotmack/claude-mem/blob/d768ba364302d12b76e69e4f021f0bb1d2d50ed6/scripts/pr-babysit-status.ts#L113-L149","documentation":"Thrown by checkPrerequisites() when `git rev-parse --is-inside-work-tree` exits non-zero or does not print 'true'. The script shells out to git for repository/PR context (and later uses gh which itself assumes a repo), so this is a hard precondition checked before any gh call.","triggerScenarios":"Running the script from a directory that is not inside any git work tree (e.g. /tmp, a fresh empty folder). Running inside a bare repo (no work tree). Running inside the .git directory itself where rev-parse behaves oddly. A git binary missing on PATH (runCommand catches and returns exitCode 127).","commonSituations":"Invoking the script from a CI checkout that wasn't cloned. Running against a tarball export of the source. A workspace where the .git folder was deleted. PATH misconfigured so git isn't found.","solutions":["cd into a checked-out clone of the repository and re-run.","If git is missing, install it and ensure it is on PATH; verify with `git --version`.","If you believe you are in a repo, run `git rev-parse --is-inside-work-tree` manually to see what git reports and fix the work tree state."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const r = runCommand(['git', 'rev-parse', '--is-inside-work-tree']);\nif (r.exitCode !== 0 || r.stdout.trim() !== 'true') {\n  console.error('Run from inside a git checkout.');\n  process.exit(1);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run the script only from inside a checked-out repository.","Call checkPrerequisites() at startup so a non-repo cwd fails fast.","In CI, ensure the checkout step ran before invoking the script."],"tags":["git","environment","precondition"],"backgroundTag":null,"analyzedSha":"d768ba364302d12b76e69e4f021f0bb1d2d50ed6","analyzedAt":"2026-08-12T23:52:55.241Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}