diff --git a/CHANGELOG.md b/CHANGELOG.md index 72107ba66..eba980dea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed +- **`bd list --watch --format` is refused instead of silently dropping the + format** ([#6277](https://github.com/gastownhall/beads/issues/6277)). + `--watch` always re-renders the pretty listing, so on the direct route a + `--format` template was ignored without a word, while `--proxied-server` + already refused the combination. Both routes now fail with the same + `--format cannot be combined with --watch` usage error. + - **The smart migrate gate no longer auto-migrates a clone whose data is behind the remote, and `bd dolt pull` now works from that state** ([#6575](https://github.com/gastownhall/beads/issues/6575)). The gate's diff --git a/cmd/bd/list_input.go b/cmd/bd/list_input.go index b637f47ff..9ffac554e 100644 --- a/cmd/bd/list_input.go +++ b/cmd/bd/list_input.go @@ -258,6 +258,13 @@ func gatherListInput(cmd *cobra.Command) (listInput, error) { in.prettyFormat = (prettyFormat || treeFormat) && !in.jsonOutput && in.formatStr == "" in.watchMode, _ = cmd.Flags().GetBool("watch") if in.watchMode { + // --watch re-renders the pretty listing on every tick, so a --format + // template would be dropped without a word (GH#6277). Refused here, + // ahead of the route split, so the direct and proxied routes answer + // the same way. + if in.formatStr != "" { + return in, HandleError("--format cannot be combined with --watch; --watch always renders the pretty listing") + } in.prettyFormat = true } in.noPager, _ = cmd.Flags().GetBool("no-pager") diff --git a/cmd/bd/list_proxied_integration_test.go b/cmd/bd/list_proxied_integration_test.go index 31ed92c41..80dd977ed 100644 --- a/cmd/bd/list_proxied_integration_test.go +++ b/cmd/bd/list_proxied_integration_test.go @@ -719,7 +719,7 @@ func TestProxiedServerList(t *testing.T) { t.Run("reject_format_with_watch", func(t *testing.T) { out := bdProxiedListFail(t, bd, p, "--watch", "--format", "dot") - if !strings.Contains(out, "--format under --proxied-server --watch is not supported") { + if !strings.Contains(out, "--format cannot be combined with --watch") { t.Errorf("expected --format+--watch rejection message, got: %s", out) } }) diff --git a/cmd/bd/list_proxied_server.go b/cmd/bd/list_proxied_server.go index f6c775c92..f993232e9 100644 --- a/cmd/bd/list_proxied_server.go +++ b/cmd/bd/list_proxied_server.go @@ -110,10 +110,7 @@ func runListProxiedPage(ctx context.Context, out io.Writer, in listInput) error } func runListProxiedWatch(_ *cobra.Command, ctx context.Context, in listInput) error { - if in.formatStr != "" { - return errors.New("--format under --proxied-server --watch is not supported") - } - + // --format with --watch is refused in gatherListInput, on both routes. uw, filter, err := openAndPrepare(ctx, in) if err != nil { return err diff --git a/cmd/bd/list_ready_brief_test.go b/cmd/bd/list_ready_brief_test.go index c7510fd5d..8dacdb44d 100644 --- a/cmd/bd/list_ready_brief_test.go +++ b/cmd/bd/list_ready_brief_test.go @@ -172,6 +172,28 @@ func TestListBriefIsRefusedWhereItCannotBeHonored(t *testing.T) { } } +// TestListWatchRefusesFormat pins GH#6277: --watch always re-renders the pretty +// listing, so a --format template would be dropped silently. The refusal lives +// in gatherListInput, ahead of the route split, so the direct route answers +// the way the proxied route used to on its own. +func TestListWatchRefusesFormat(t *testing.T) { + pinJSONOutput(t, false) + _, err, shown := runGatherListInput(t, newListFlagsCommand(t, "--watch", "--format", "digraph")) + if err == nil { + t.Fatal("gatherListInput(--watch --format digraph) = nil, want a usage error") + } + if want := "--format cannot be combined with --watch"; !strings.Contains(shown, want) { + t.Errorf("output = %q, want it to name %q", shown, want) + } + + // The control: --watch alone and --format alone are both still accepted. + for _, args := range [][]string{{"--watch"}, {"--format", "digraph"}} { + if _, err := gatherListInput(newListFlagsCommand(t, args...)); err != nil { + t.Errorf("gatherListInput(%v) = %v, want no error", args, err) + } + } +} + // TestListBriefIsAcceptedOnThePageRoutes is the negative control: the modes // above are refusals, not a blanket one. --long is here on purpose, since it is // the text rendering that prints an omitted field and is allowed precisely