gabriel / muse public
feat patch task/bridge-hooks #1 / 1
AI Agent gabriel · 121 days ago · May 18, 2026 · Diff

feat: implement .muse/bridge-hooks.toml pre/post hook system for git-export

- Add BridgeHook and BridgeHooks dataclasses - Add load_bridge_hooks(muse_root) — reads/validates bridge-hooks.toml - Add run_hook / run_hooks — execute hooks with cwd and MUSE_BRIDGE_* env vars - Wire pre_bridge hooks (cwd=muse_root) before sync_to_git in run_git_export - Wire post_bridge hooks (cwd=git_dir) after git_commit in run_git_export - Hoist find_repo_root to module-level import so tests can patch it - Fix test_post_bridge_hooks_run_after_commit tuple unpacking in TDD suite

Closes #55 (musehub)

sha256:2a9ffde71a16c3a44ffa98f5cad6f0fda85f82782c0d77f3a6d1653e952bebd1 sha
+43 ~1 symbols
sha256:dc90726cc2ca193ecfc13b1c911a6a832ee55b3b8ee7692f5934d54965714e8f snapshot
+43
symbols added
~1
symbol modified
0
dead code introduced
Semantic Changes 44 symbols
~ tests/test_bridge_hooks.py .py 37 symbols added
+ TestGitExportHookIntegration class class TestGitExportHookIntegration L334–677
+ _make_args method method _make_args L337–359
+ test_blocking_pre_hook_failure_aborts_export method method test_blocking_pre_hook_failure_aborts_export L567–601
+ test_env_vars_injected_into_hooks method method test_env_vars_injected_into_hooks L603–649
+ test_no_hooks_file_export_runs_normally method method test_no_hooks_file_export_runs_normally L651–677
+ test_post_bridge_hooks_run_after_commit method method test_post_bridge_hooks_run_after_commit L417–475
+ test_post_bridge_hooks_run_in_git_dir method method test_post_bridge_hooks_run_in_git_dir L477–520
+ test_pre_bridge_hooks_run_before_sync method method test_pre_bridge_hooks_run_before_sync L361–415
+ test_pre_bridge_hooks_run_in_muse_root method method test_pre_bridge_hooks_run_in_muse_root L522–565
+ TestLoadBridgeHooks class class TestLoadBridgeHooks L47–153
+ test_invalid_on_fail_value_raises_user_error method method test_invalid_on_fail_value_raises_user_error L127–139
+ test_invalid_toml_raises_user_error method method test_invalid_toml_raises_user_error L116–125
+ test_loads_post_bridge_hooks method method test_loads_post_bridge_hooks L79–98
+ test_loads_pre_bridge_hooks method method test_loads_pre_bridge_hooks L59–77
+ test_missing_run_field_raises_user_error method method test_missing_run_field_raises_user_error L141–153
+ test_returns_empty_hooks_when_file_missing method method test_returns_empty_hooks_when_file_missing L50–57
+ test_returns_empty_sections_when_section_missing method method test_returns_empty_sections_when_section_missing L100–114
+ TestRunHook class class TestRunHook L160–247
+ test_block_hook_raises_on_nonzero_exit method method test_block_hook_raises_on_nonzero_exit L204–215
+ test_hook_injects_env_vars method method test_hook_injects_env_vars L180–202
+ test_hook_runs_in_given_cwd method method test_hook_runs_in_given_cwd L163–178
+ test_successful_hook_does_not_raise method method test_successful_hook_does_not_raise L236–247
+ test_warn_hook_does_not_raise_on_nonzero_exit method method test_warn_hook_does_not_raise_on_nonzero_exit L217–234
+ TestRunHooks class class TestRunHooks L250–327
+ test_block_failure_stops_subsequent_hooks method method test_block_failure_stops_subsequent_hooks L274–297
+ test_empty_hook_list_is_a_noop method method test_empty_hook_list_is_a_noop L320–327
+ test_runs_all_hooks_in_order method method test_runs_all_hooks_in_order L253–272
+ test_warn_failure_continues_to_next_hook method method test_warn_failure_continues_to_next_hook L299–318
+ MagicMock import import MagicMock L38–38
+ annotations import import annotations L32–32
+ call import import call L38–38
+ patch import import patch L38–38
+ pathlib import import pathlib L34–34
+ pytest import import pytest L40–40
+ subprocess import import subprocess L35–35
+ sys import import sys L36–36
+ textwrap import import textwrap L37–37
~ muse/cli/commands/bridge.py .py 6 symbols added, 1 symbol modified
+ BridgeHook class class BridgeHook L161–165
+ BridgeHooks class class BridgeHooks L169–173
+ find_repo_root import import find_repo_root L53–53
+ load_bridge_hooks function function load_bridge_hooks L176–219
+ run_hook function function run_hook L222–248
+ run_hooks function function run_hooks L251–260
← Older Oldest on task/bridge-hooks
All commits
Newer → Latest on task/bridge-hooks

0 comments

No comments yet. Be the first to start the discussion.

To add a comment, use the Muse CLI: muse hub commit comment sha256:2a9ffde71a16c3a44ffa98f5cad6f0fda85f82782c0d77f3a6d1653e952bebd1 --body "your comment"