fix(uninstall): explain all-dirty batch failures

This commit is contained in:
hhh2210
2026-07-15 09:30:54 +08:00
committed by Willie
parent c5f876c79e
commit e2c0a64247
2 changed files with 20 additions and 0 deletions
+3
View File
@@ -866,6 +866,9 @@ func cmdUninstall(args []string) error {
if len(targets) == 0 {
preflightErr := fmt.Errorf("no skills to uninstall after pre-flight checks")
if preflightSkipped > 0 {
preflightErr = fmt.Errorf("%d tracked repo%s skipped due to uncommitted changes; use --force to override", preflightSkipped, pluralS(preflightSkipped))
}
if opts.jsonOutput {
return writeJSONError(preflightErr)
}
+17
View File
@@ -727,6 +727,23 @@ func TestUninstall_JSON_DirtyRepoRequiresExplicitForce(t *testing.T) {
t.Fatal("dirty tracked repo should remain without explicit --force")
}
// An all-dirty batch should explain why pre-flight rejected every target.
secondRepoPath := sb.SourcePath + "/_uninst-preflight-2"
run(t, sb.Root, "git", "clone", remoteDir, secondRepoPath)
sb.WriteFile(secondRepoPath+"/dirty.txt", "uncommitted")
result = sb.RunCLI("uninstall", "uninst-preflight", "uninst-preflight-2", "--json")
result.AssertFailure(t)
assertPureJSON(t, strings.TrimSpace(result.Stdout))
output = parseJSON(t, result.Stdout)
errorMessage, _ := output["error"].(string)
if !strings.Contains(errorMessage, "uncommitted changes") {
t.Fatalf("expected actionable dirty-repo error, got %q", errorMessage)
}
if !sb.FileExists(repoPath) || !sb.FileExists(secondRepoPath) {
t.Fatal("all dirty tracked repos should remain without explicit --force")
}
// Batch JSON output should stay pure while skipping only the dirty repo.
sb.CreateSkill("clean-skill", map[string]string{"SKILL.md": "# Clean"})
result = sb.RunCLI("uninstall", "uninst-preflight", "clean-skill", "--json")