{"record":{"id":"737e433c2d50d305","repo":"Hmbown/CodeWhale","slug":"a-full-git-history-is-required-to-establish-the-pr-merge","errorCode":null,"errorMessage":"A full Git history is required to establish the PR merge base","messagePattern":"A full Git history is required to establish the PR merge base","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/tools/review_pr.rs","lineNumber":274,"sourceCode":"    // completeness: also check the metadata's changed-file count.\n    let remote = if view.changed_files <= 300 {\n        run(Program::Gh, &pr_args(\"diff\", number, repo)).and_then(|diff| {\n            complete_file_set(&diff, view)?;\n            Ok(diff)\n        })\n    } else {\n        Err(anyhow::anyhow!(\"GitHub diff exceeds its 300-file limit\"))\n    };\n    let diff = match remote {\n        Ok(diff) => diff,\n        Err(remote_error) => {\n            let local: Result<String> = (|| {\n                let shallow = run(\n                    Program::Git,\n                    &[\"rev-parse\".into(), \"--is-shallow-repository\".into()],\n                )?;\n                if shallow.trim() != \"false\" {\n                    bail!(\"A full Git history is required to establish the PR merge base\");\n                }\n                let base = run(\n                    Program::Git,\n                    &[\n                        \"merge-base\".into(),\n                        \"--all\".into(),\n                        view.base_sha.clone(),\n                        view.head_sha.clone(),\n                    ],\n                )?;\n                let base = base.trim();\n                if !commit_id(base) {\n                    bail!(\"The pinned PR commits do not have one available merge base\");\n                }\n                let diff = run(\n                    Program::Git,\n                    &[\n                        \"diff\".into(),","sourceCodeStart":256,"sourceCodeEnd":292,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/tools/review_pr.rs#L256-L292","documentation":"diff_with first tries GitHub's diff; on fallback it computes the merge base locally with `git merge-base --all`. Before that it checks `git rev-parse --is-shallow-repository`; a shallow clone cannot reliably establish the PR merge base, so the tool refuses instead of producing a diff against a fabricated base.","triggerScenarios":"fetch_diff's fallback path runs in a repo where `git rev-parse --is-shallow-repository` prints anything other than `false` (typically `true` from a CI checkout with fetch-depth: 1).","commonSituations":"GitHub Actions / other CI with shallow checkouts; `git clone --depth` or `--shallow-since` local clones; gitpod/devcontainer shallow init scripts.","solutions":["Unshallow the repo: `git fetch --unshallow origin` (or `git fetch --deepen=...`), then rerun the review","In CI, raise the checkout depth (e.g. actions/checkout with fetch-depth: 0)","Verify with `git rev-parse --is-shallow-repository` that it now prints `false` before retrying"],"exampleFix":"// before: CI shallow checkout\n- uses: actions/checkout@v4\n  with:\n    fetch-depth: 1\n// after: full history so merge-base works\n- uses: actions/checkout@v4\n  with:\n    fetch-depth: 0","handlingStrategy":"fallback","validationCode":"// fail before calling the tool if the clone is shallow\nlet shallow = git rev-parse --is-shallow-repository;\nif shallow.trim() != \"false\" {\n    bail!(\"unshallow first: git fetch --unshallow origin\");\n}","typeGuard":null,"tryCatchPattern":"let out = Command::new(\"git\").args([\"rev-parse\",\"--is-shallow-repository\"]).output()?;\nif String::from_utf8_lossy(&out.stdout).trim() != \"false\" {\n    Command::new(\"git\").args([\"fetch\",\"--unshallow\",\"origin\"]).status()?;\n}\n// then retry the review","preventionTips":["Use fetch-depth: 0 in CI checkouts","Avoid `git clone --depth`/--shallow-since for review workspaces","Check `git rev-parse --is-shallow-repository` in environment setup and unshallow proactively"],"tags":["git","shallow-clone","ci","merge-base"],"backgroundTag":"git-command-failed","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-22T16:17:23.217Z"}