fix(list): refuse --watch with --format on the direct route too (#6277) (#6707)

--watch forces the pretty listing and returns into the watch loop before
the --format branch, so on the direct route `bd list --watch --format X`
printed the pretty listing and never mentioned the ignored template. The
proxied route already refused the combination in runListProxiedWatch.

The refusal now lives in gatherListInput, next to the existing --watch /
--brief refusal and ahead of the route split, so both routes give the same
usage error. The proxied-only guard is unreachable now and is removed, and
its integration test expects the shared message.

Agent-Signature: claude-code-opus-5-5-unknown-reasoning on behalf of Harry Miller

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Harry Miller 2026-09-26 07:32:57 -07:00 • committed by GitHub
commit c2f5029e10
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 38 additions and 5 deletions

View file

@ -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

View file

@ -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")

View file

@ -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)
}
})

View file

@ -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

View file

@ -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