From e2c0a64247ae322ab1bde580cbc4bad91d3d7f93 Mon Sep 17 00:00:00 2001 From: hhh2210 Date: Sun, 12 Jul 2026 22:22:38 +0800 Subject: [PATCH] fix(uninstall): explain all-dirty batch failures --- cmd/skillshare/uninstall.go | 3 +++ tests/integration/json_output_test.go | 17 +++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/cmd/skillshare/uninstall.go b/cmd/skillshare/uninstall.go index 673adbd7e..6d5e7e14b 100644 --- a/cmd/skillshare/uninstall.go +++ b/cmd/skillshare/uninstall.go @@ -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) } diff --git a/tests/integration/json_output_test.go b/tests/integration/json_output_test.go index 169e4a741..b0d98e889 100644 --- a/tests/integration/json_output_test.go +++ b/tests/integration/json_output_test.go @@ -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")