{"record":{"id":"e6f0202202f031ea","repo":"can1357/oh-my-pi","slug":"not-a-repository-path","errorCode":null,"errorMessage":"not a repository: {path}","messagePattern":"not a repository: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"crates/pi-vcs/src/error.rs","lineNumber":16,"sourceCode":"//! Error type shared by the git and jj backends.\n//!\n//! Failure modes that TypeScript callers previously detected by regexing\n//! subprocess stderr (e.g. an empty cherry-pick) are first-class variants here\n//! so the TS layer can match on a structured `kind` instead of message text.\n\nuse std::path::PathBuf;\n\n/// Crate-wide result alias.\npub type Result<T, E = Error> = std::result::Result<T, E>;\n\n/// Unified error for all VCS operations.\n#[derive(Debug, thiserror::Error)]\npub enum Error {\n\t/// The directory is not inside a git repository / jj workspace.\n\t#[error(\"not a repository: {path}\")]\n\tNotARepository {\n\t\t/// Directory the lookup started from.\n\t\tpath: PathBuf,\n\t},\n\n\t/// A named ref (branch, tag, `refs/...`) does not exist.\n\t#[error(\"reference not found: {name}\")]\n\tRefNotFound {\n\t\t/// The ref name as given by the caller.\n\t\tname: String,\n\t},\n\n\t/// A revision/object lookup failed (`rev-parse` style spec, blob path,\n\t/// tree).\n\t#[error(\"object not found: {spec}\")]\n\tObjectNotFound {\n\t\t/// The revision or object spec as given by the caller.\n\t\tspec: String,","sourceCodeStart":1,"sourceCodeEnd":34,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/crates/pi-vcs/src/error.rs#L1-L34","documentation":"The unified pi-vcs Error::NotARepository variant. The library could not find a git repository root or jj workspace at or above the directory a VCS operation started from. It is thrown during repository discovery (walking up parent directories looking for .git / .jj) before any VCS API calls can proceed.","triggerScenarios":"Opening a Vcs/repo handle with a path that is outside any git repository or jj workspace: e.g. Vcs::open(\"/tmp\"), or a git/jj command rooted at a scratch directory, home dir, or a fresh empty folder with no `git init`.","commonSituations":"Running the tool before `git init`, running in a subdirectory that was never inside a repo, a deleted or renamed .git directory, CI checkouts that extracted a tarball without .git, or pointing config at the wrong working directory.","solutions":["Run `git init` in the target directory (or `jj git init` for a jj workspace).","cd into a directory that is actually inside the repository, or pass the repo root path explicitly.","Verify the .git directory exists and was not deleted/moved (`ls -a .git`).","In code, check for this variant first and surface a friendly 'run git init' message instead of a raw error."],"exampleFix":"// before\nlet repo = Vcs::open(\"/tmp/scratch\")?; // panics-ish: not a repository\n// after\nif !git_probe::is_repo(\"/tmp/scratch\") {\n    std::process::Command::new(\"git\").args([\"init\"]).current_dir(\"/tmp/scratch\").status()?;\n}\nlet repo = Vcs::open(\"/tmp/scratch\")?;","handlingStrategy":"validation","validationCode":"fn is_vcs_dir(dir: &Path) -> bool {\n    let mut cur = Some(dir);\n    while let Some(d) = cur {\n        if d.join(\".git\").exists() || d.join(\".jj\").exists() { return true; }\n        cur = d.parent();\n    }\n    false\n}\nif !is_vcs_dir(&workdir) { eprintln!(\"{} is not inside a git/jj repository\", workdir.display()); return Ok(()); }","typeGuard":"fn is_not_a_repository(err: &pi_vcs::Error) -> bool {\n    matches!(err, pi_vcs::Error::NotARepository { .. })\n}","tryCatchPattern":"match repo_result {\n    Err(pi_vcs::Error::NotARepository { path }) => {\n        eprintln!(\"{} is not a git/jj repository — run `git init` first\", path.display());\n    }\n    other => other?,\n}","preventionTips":["Run `git init` before any tooling that reads VCS state in a new project.","Resolve the repo root once at startup (e.g. `git rev-parse --show-toplevel`) and anchor all operations there.","In CI, always use a full checkout (`actions/checkout`) rather than a tarball download so .git exists.","Probe for .git/.jj when configuring working-directory settings."],"tags":["vcs","git","repository-not-found","filesystem"],"backgroundTag":"not-a-git-repository","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}