summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
Diffstat (limited to 'cmd')
-rw-r--r--cmd/krino/explain.go3
-rw-r--r--cmd/krino/history_test.go9
-rw-r--r--cmd/krino/undo.go2
3 files changed, 12 insertions, 2 deletions
diff --git a/cmd/krino/explain.go b/cmd/krino/explain.go
index 8d5418e..5f9f6de 100644
--- a/cmd/krino/explain.go
+++ b/cmd/krino/explain.go
@@ -26,6 +26,9 @@ func cmdExplain(g *globals, args []string, stdout, stderr io.Writer) int {
if fs.NArg() != 1 {
return usageError(stderr, "usage: krino explain FILE")
}
+ if code, refused := refuseUnusedFlags(g, stderr, "explain", false); refused {
+ return code
+ }
minAge, setMinAge, err := minAgeOverride(g)
if err != nil {
return usageError(stderr, err.Error())
diff --git a/cmd/krino/history_test.go b/cmd/krino/history_test.go
index 7c0f810..9c409bc 100644
--- a/cmd/krino/history_test.go
+++ b/cmd/krino/history_test.go
@@ -142,11 +142,14 @@ func TestFinalizeUndoPlanMarksUnapprovedAsDeclined(t *testing.T) {
{File: "a"}, // index 0: approved
{File: "b"}, // index 1: not approved -> declined
{File: "c", Refused: "gone"}, // index 2: refused, never declined
- }}
+ }, Cleanup: []engine.UndoFile{{File: "d"}}}
out, _ := finalizeUndoPlan(up, map[int]bool{0: true}, 'c')
if len(out.Files) != 3 {
t.Fatalf("files = %+v, want all three carried through", out.Files)
}
+ if len(out.Cleanup) != 1 || out.Cleanup[0].File != "d" {
+ t.Errorf("Cleanup = %+v, want the plan's directory cleanup carried over", out.Cleanup)
+ }
if out.Files[0].Declined || out.Files[0].Refused != "" {
t.Errorf("approved file changed: %+v", out.Files[0])
}
@@ -542,6 +545,10 @@ func TestIgnoredGlobalFlagsAreRefused(t *testing.T) {
{"-v", "log"},
{"--json", "undo", "-n"},
{"-v", "undo", "-n"},
+ {"-y", "explain", dl},
+ {"-n", "explain", dl},
+ {"--json", "explain", dl},
+ {"-v", "explain", dl},
} {
if code, _, errOut := runCLI(t, args...); code != 2 || !strings.Contains(errOut, "does not take") {
t.Errorf("krino %q: exit %d, stderr %q; want 2, refused", args, code, errOut)
diff --git a/cmd/krino/undo.go b/cmd/krino/undo.go
index 1b5e6ae..4c71fdd 100644
--- a/cmd/krino/undo.go
+++ b/cmd/krino/undo.go
@@ -317,7 +317,7 @@ func releaseUndoLocks(locks []*lock.Lock) []error {
// left out of the plan entirely, as review's [w] leaves a forward file
// unlogged, and counted in notReviewed (review cli F2).
func finalizeUndoPlan(up *engine.UndoPlan, approved map[int]bool, action rune) (plan *engine.UndoPlan, notReviewed int) {
- out := &engine.UndoPlan{Run: up.Run}
+ out := &engine.UndoPlan{Run: up.Run, Cleanup: up.Cleanup}
for i, f := range up.Files {
if f.Refused == "" {
yes, decided := approved[i]