Skip to content

Commit 0a042aa

Browse files
committed
Output hooks scripts by default
1 parent 697c23d commit 0a042aa

File tree

3 files changed

+17
-9
lines changed

3 files changed

+17
-9
lines changed

bumpversion/hooks.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,9 @@ def run_hooks(hooks: List[str], env: Dict[str, str], dry_run: bool = False) -> N
9797
logger.indent()
9898
for script in hooks:
9999
if dry_run:
100-
logger.debug(f"Would run {script!r}")
100+
logger.info(f"Would run {script!r}")
101101
continue
102-
logger.debug(f"Running {script!r}")
102+
logger.info(f"Running {script!r}")
103103
logger.indent()
104104
result = run_command(script, env)
105105
if result.returncode != 0:

tests/test_hooks/test_run_hook_suites.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,12 @@ def test_calls_each_hook(self, mocker, suite_name: str, suite_func: Callable, su
6363
suite_func(config, *suite_args)
6464

6565
# Assert
66-
mock_logger.info.assert_called_once_with(f"Running {suite_name} hooks:".replace("_", "-"))
66+
expected_info_calls = [
67+
mocker.call(f"Running {suite_name} hooks:".replace("_", "-")),
68+
mocker.call("Running 'script1'"),
69+
mocker.call("Running 'script2'"),
70+
]
71+
mock_logger.info.assert_has_calls(expected_info_calls)
6772
mock_env.assert_called_once_with(config, *suite_args)
6873
expected_run_command_calls = [
6974
mocker.call("script1", env),

tests/test_hooks/test_run_hooks.py

+9-6
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,20 @@ def test_calls_each_hook(mocker):
1919
hooks.run_hooks(hooks_list, env)
2020

2121
# Assert
22-
expected_calls = [
22+
expected_info_calls = [
2323
mocker.call("Running 'script1'"),
24+
mocker.call("Running 'script2'"),
25+
]
26+
mock_logger.info.assert_has_calls(expected_info_calls)
27+
expected_debug_calls = [
2428
mocker.call("Exited with 0"),
2529
mocker.call("output"),
2630
mocker.call("error"),
27-
mocker.call("Running 'script2'"),
2831
mocker.call("Exited with 0"),
2932
mocker.call("output"),
3033
mocker.call("error"),
3134
]
32-
mock_logger.debug.assert_has_calls(expected_calls)
35+
mock_logger.debug.assert_has_calls(expected_debug_calls)
3336
mock_run_command.assert_any_call("script1", env)
3437
mock_run_command.assert_any_call("script2", env)
3538

@@ -48,9 +51,9 @@ def test_raises_exception_if_hook_fails(mocker):
4851
hooks.run_hooks(hooks_list, env)
4952

5053
# Assert
51-
expected_debug_calls = [mocker.call("Running 'script1'")]
54+
expected_info_calls = [mocker.call("Running 'script1'")]
5255
expected_warning_calls = [mocker.call("output"), mocker.call("error")]
53-
mock_logger.debug.assert_has_calls(expected_debug_calls)
56+
mock_logger.info.assert_has_calls(expected_info_calls)
5457
mock_logger.warning.assert_has_calls(expected_warning_calls)
5558
mock_run_command.assert_any_call("script1", env)
5659

@@ -68,5 +71,5 @@ def test_does_not_call_each_hook_when_dry_run(mocker):
6871

6972
# Assert
7073
expected_calls = [mocker.call("Would run 'script1'"), mocker.call("Would run 'script2'")]
71-
mock_logger.debug.assert_has_calls(expected_calls)
74+
mock_logger.info.assert_has_calls(expected_calls)
7275
mock_run_command.assert_not_called()

0 commit comments

Comments
 (0)