{"record":{"id":"7b4fbbaf438fa113","repo":"nikivdev/code","slug":"working-tree-has-uncommitted-changes-commit-stash","errorCode":null,"errorMessage":"working tree has uncommitted changes; commit/stash them or rerun with --stash","messagePattern":"working tree has uncommitted changes; commit/stash them or rerun with --stash","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/fix.rs","lineNumber":250,"sourceCode":"    let root = String::from_utf8_lossy(&output.stdout).trim().to_string();\n    if root.is_empty() {\n        bail!(\"failed to resolve git repository root\");\n    }\n    Ok(std::path::PathBuf::from(root))\n}\n\nfn ensure_clean_or_stash(\n    repo_root: &std::path::Path,\n    allow_stash: bool,\n    stashed: &mut bool,\n) -> Result<()> {\n    let status = git_output(repo_root, &[\"status\", \"--porcelain\"])?;\n    if status.trim().is_empty() {\n        return Ok(());\n    }\n\n    if !allow_stash {\n        bail!(\"working tree has uncommitted changes; commit/stash them or rerun with --stash\");\n    }\n\n    println!(\"Stashing local changes...\");\n    git_status(\n        repo_root,\n        &[\"stash\", \"push\", \"-u\", \"-m\", \"f fix auto-stash\"],\n    )?;\n    *stashed = true;\n    Ok(())\n}\n\nfn ensure_has_parent_commit(repo_root: &std::path::Path) -> Result<()> {\n    let output = Command::new(\"git\")\n        .args([\"rev-parse\", \"HEAD~1\"])\n        .current_dir(repo_root)\n        .output()\n        .context(\"failed to check git history\")?;\n    if !output.status.success() {","sourceCodeStart":232,"sourceCodeEnd":268,"githubUrl":"https://github.com/nikivdev/code/blob/a747e741ae92c09071d0ae946ab48488adcff1ce/src/fix.rs#L232-L268","documentation":"Error \"working tree has uncommitted changes; commit/stash them or rerun with --stash\" thrown in nikivdev/code.","triggerScenarios":"Thrown at src/fix.rs:250 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"a747e741ae92c09071d0ae946ab48488adcff1ce","analyzedAt":"2026-09-01T22:43:55.719Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}