{"record":{"id":"d21db83c75759c7d","repo":"zed-industries/zed","slug":"working-directory-is-not-clean-please-commit-or-stash-your","errorCode":null,"errorMessage":"Working directory is not clean. Please commit or stash your changes before publishing.","messagePattern":"Working directory is not clean\\. Please commit or stash your changes before publishing\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"tooling/xtask/src/tasks/gpui.rs","lineNumber":322,"sourceCode":"\n    Ok(())\n}\n\nfn check_git_clean() -> Result<()> {\n    let output = run_command(\n        Command::new(\"git\")\n            .args([\"status\", \"--porcelain\"])\n            .stdout(Stdio::piped())\n            .stderr(Stdio::piped()),\n    )?;\n\n    if !output.status.success() {\n        bail!(\"git status command failed\");\n    }\n\n    let stdout = String::from_utf8_lossy(&output.stdout);\n    if !stdout.trim().is_empty() {\n        bail!(\n            \"Working directory is not clean. Please commit or stash your changes before publishing.\"\n        );\n    }\n\n    Ok(())\n}\n\nfn run_command(command: &mut Command) -> Result<Output> {\n    let command_str = {\n        let program = command.get_program().to_string_lossy();\n        let args = command\n            .get_args()\n            .map(|arg| arg.to_string_lossy())\n            .collect::<Vec<_>>()\n            .join(\" \");\n\n        if args.is_empty() {\n            program.to_string()","sourceCodeStart":304,"sourceCodeEnd":340,"githubUrl":"https://github.com/zed-industries/zed/blob/916fc2b8cb3a815cbef4a3b40e13081be72036b6/tooling/xtask/src/tasks/gpui.rs#L304-L340","documentation":"The GPUI publish xtask aborts when `git status --porcelain` reports any tracked-but-modified, staged, or untracked files. Publishing requires a clean tree so that version bumps and generated changes are reproducible and nothing unintended is mixed into the release. check_git_clean runs the git command via run_command and bails whenever the porcelain output is non-empty.","triggerScenarios":"Running `cargo xtask publish-gpui` (run_publish_gpui -> check_git_clean) while the working tree has uncommitted modifications, staged changes, or untracked files. Also triggered if .gitignore is broken so stray files show in porcelain output.","commonSituations":"Developer edits Cargo.toml versions manually before publishing; leftover build artifacts or scratch files not gitignored; half-finished feature work in the repo when trying to cut a release.","solutions":["Run `git status --porcelain` to see the offending files, then `git add -A && git commit` them","Run `git stash -u` to shelve changes, publish, then `git stash pop`","Remove or gitignore stray untracked files (e.g. editor artifacts, temp files)","Ensure the command is run from the intended workspace root, not a dirty copy of the repo"],"exampleFix":"// before (dirty tree)\n$ cargo xtask publish-gpui\n// Error: Working directory is not clean...\n\n// after\n$ git add -A && git commit -m \"Prepare release\"\n$ cargo xtask publish-gpui","handlingStrategy":"validation","validationCode":"let status = std::process::Command::new(\"git\")\n    .args([\"status\", \"--porcelain\"])\n    .output()?;\nif !String::from_utf8_lossy(&status.stdout).trim().is_empty() {\n    anyhow::bail!(\"Commit or stash changes before publishing\");\n}","typeGuard":"fn is_git_clean() -> bool {\n    let out = std::process::Command::new(\"git\")\n        .args([\"status\", \"--porcelain\"])\n        .output()\n        .map(|o| o.status.success());\n    out.map(|ok| ok && std::str::from_utf8(&out.unwrap().stdout).map(|s| s.trim().is_empty()).unwrap_or(false)).unwrap_or(false)\n}","tryCatchPattern":null,"preventionTips":["Run `git status --porcelain` before any release command as a preflight check","Keep .gitignore up to date for build artifacts and editor files","Automate releases from CI on a freshly checked-out, clean tree","Commit or stash WIP before starting release tooling"],"tags":["git","publishing","cli"],"backgroundTag":"git-command-failed","analyzedSha":"916fc2b8cb3a815cbef4a3b40e13081be72036b6","analyzedAt":"2026-09-19T19:09:50.599Z","contentChangedAt":"2026-09-19T19:09:50.599Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}