diff --git a/cmd/root.go b/cmd/root.go index 501da40..45422bc 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -1,6 +1,7 @@ package cmd import ( + "bytes" "fmt" "os" "os/exec" @@ -663,7 +664,20 @@ func cmdPurge(_ []string) error { fmt.Println() fmt.Printf(" %s⚠ DESTRUCTIVE OPERATION%s\n", r, rst) fmt.Println() - fmt.Printf(" This will permanently remove all %s%d mob(s)%s and their worktrees.\n", r, len(cfg.Mobs), rst) + fmt.Println(" The following mobs will be permanently removed:") + fmt.Println() + var buf bytes.Buffer + w := tabwriter.NewWriter(&buf, 0, 0, 2, ' ', 0) + fmt.Fprintln(w, "NAME\tBRANCH") + for _, m := range cfg.Mobs { + branch := mob.ActualBranch(root, cfg, &m) + fmt.Fprintf(w, "%s\t%s\n", m.Name, branch) + } + w.Flush() + for _, line := range strings.Split(strings.TrimRight(buf.String(), "\n"), "\n") { + fmt.Printf(" %s\n", line) + } + fmt.Println() fmt.Printf(" Any %suncommitted or unpushed changes%s in those worktrees will be %spermanently lost%s.\n", r, rst, r, rst) fmt.Println() fmt.Printf(" %sThis cannot be undone.%s\n", r, rst) diff --git a/internal/mob/integration_test.go b/internal/mob/integration_test.go index 6ac0f7b..cb6450c 100644 --- a/internal/mob/integration_test.go +++ b/internal/mob/integration_test.go @@ -766,6 +766,15 @@ func TestPurge(t *testing.T) { t.Fatalf("clear failed: %s\n%s", err, out) } + // then -> output lists mob names and branches before confirmation + outStr := string(out) + if !strings.Contains(outStr, "one") || !strings.Contains(outStr, "mob/one") { + t.Errorf("purge output should list mob 'one' with branch, got: %s", outStr) + } + if !strings.Contains(outStr, "two") || !strings.Contains(outStr, "mob/two") { + t.Errorf("purge output should list mob 'two' with branch, got: %s", outStr) + } + // then -> no mobs cfg := readConfig(t, repoPath) mobs, _ := cfg["mobs"].([]interface{})