Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit dab8a7f

Browse files
committed
fix(bump): fixed environment variables in bump hooks
During development of #644, merging the hook environment variables with existing OS variables broke.
1 parent 1ff575d commit dab8a7f

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

‎commitizen/hooks.py‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
from commitizen import cmd, out
44
from commitizen.exceptions import RunHookError
55

6+
import os
7+
68

79
def run(hooks, _env_prefix="CZ_", **env):
810
if isinstance(hooks, str):
@@ -25,7 +27,7 @@ def run(hooks, _env_prefix="CZ_", **env):
2527
def _format_env(prefix: str, env: dict[str, str]) -> dict[str, str]:
2628
"""_format_env() prefixes all given environment variables with the given
2729
prefix so it can be passed directly to cmd.run()."""
28-
penv = dict()
30+
penv = dict(os.environ)
2931
for name, value in env.items():
3032
name = prefix + name.upper()
3133
value = str(value) if value is not None else ""

‎tests/test_bump_hooks.py‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import os
12
from unittest.mock import call
23

34
import pytest
@@ -17,7 +18,10 @@ def test_run(mocker: MockFixture):
1718
hooks.run(bump_hooks)
1819

1920
cmd_run_mock.assert_has_calls(
20-
[call("pre_bump_hook", env={}), call("pre_bump_hook_1", env={})]
21+
[
22+
call("pre_bump_hook", env=dict(os.environ)),
23+
call("pre_bump_hook_1", env=dict(os.environ)),
24+
]
2125
)
2226

2327

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /