fix(kanban): keep board-management commands independent from board override
This commit is contained in:
@@ -692,6 +692,14 @@ def kanban_command(args: argparse.Namespace) -> int:
|
|||||||
)
|
)
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
# Board-management commands operate on board metadata and the persisted
|
||||||
|
# current-board pointer itself. They must ignore the shared `--board`
|
||||||
|
# task-routing override; otherwise `/kanban --board beta boards show`
|
||||||
|
# reports beta as the current board even when the on-disk pointer is
|
||||||
|
# alpha.
|
||||||
|
if action == "boards":
|
||||||
|
return _dispatch_boards(args)
|
||||||
|
|
||||||
# `--board <slug>` applies to every subcommand below by way of an
|
# `--board <slug>` applies to every subcommand below by way of an
|
||||||
# env-var pin for the duration of this call. Using HERMES_KANBAN_BOARD
|
# env-var pin for the duration of this call. Using HERMES_KANBAN_BOARD
|
||||||
# (rather than threading `board=` through 50+ kb.connect() sites)
|
# (rather than threading `board=` through 50+ kb.connect() sites)
|
||||||
@@ -729,15 +737,6 @@ def kanban_command(args: argparse.Namespace) -> int:
|
|||||||
os.environ["HERMES_KANBAN_BOARD"] = normed
|
os.environ["HERMES_KANBAN_BOARD"] = normed
|
||||||
restore_board_env = True
|
restore_board_env = True
|
||||||
|
|
||||||
# Boards management doesn't touch the DB at all — dispatch early so
|
|
||||||
# fresh installs that haven't initialized any DB can still use
|
|
||||||
# `hermes kanban boards create …`.
|
|
||||||
if action == "boards":
|
|
||||||
try:
|
|
||||||
return _dispatch_boards(args)
|
|
||||||
finally:
|
|
||||||
_restore_board_env()
|
|
||||||
|
|
||||||
# Auto-initialize the DB before dispatching any subcommand. init_db
|
# Auto-initialize the DB before dispatching any subcommand. init_db
|
||||||
# is idempotent, so running it every invocation is cheap (one
|
# is idempotent, so running it every invocation is cheap (one
|
||||||
# SELECT against sqlite_master when tables already exist) and
|
# SELECT against sqlite_master when tables already exist) and
|
||||||
|
|||||||
@@ -402,3 +402,13 @@ def test_run_slash_board_override_restores_prior_env(kanban_home, monkeypatch):
|
|||||||
kc.run_slash("--board alpha list")
|
kc.run_slash("--board alpha list")
|
||||||
|
|
||||||
assert os.environ.get("HERMES_KANBAN_BOARD") == "beta"
|
assert os.environ.get("HERMES_KANBAN_BOARD") == "beta"
|
||||||
|
|
||||||
|
|
||||||
|
def test_run_slash_board_override_does_not_change_boards_show_current(kanban_home):
|
||||||
|
kb.create_board("alpha")
|
||||||
|
kb.create_board("beta")
|
||||||
|
kb.set_current_board("alpha")
|
||||||
|
|
||||||
|
out = kc.run_slash("--board beta boards show")
|
||||||
|
|
||||||
|
assert "Current board: alpha" in out
|
||||||
|
|||||||
Reference in New Issue
Block a user