Skip to content

Commit 847b4ba

Browse files
committed
fix(commit): resolve 'always_signoff' configuration and '-s' CLI issues
If 'always_signoff' is enabled in configurations, or '-s' is used alone on the CLI, the following errors arise due to 'git commit' argument failures : > signoff mechanic is deprecated, please use `cz commit -- -s` instead. > fatal: /tmp/...: '/tmp/... is outside repository at '...' Signed-off-by: Adrian DC <radian.dc@gmail.com>
1 parent 01fd042 commit 847b4ba

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

Diff for: commitizen/commands/commit.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -114,13 +114,15 @@ def __call__(self):
114114
self.arguments.get("signoff") or self.config.settings["always_signoff"]
115115
)
116116

117+
extra_args = self.arguments.get("extra_cli_args", "")
118+
117119
if signoff:
118120
out.warn(
119121
"signoff mechanic is deprecated, please use `cz commit -- -s` instead."
120122
)
121-
extra_args = self.arguments.get("extra_cli_args", "--") + " -s"
122-
else:
123-
extra_args = self.arguments.get("extra_cli_args", "")
123+
if extra_args:
124+
extra_args += " "
125+
extra_args += "-s"
124126

125127
c = git.commit(m, args=extra_args)
126128

Diff for: tests/commands/test_commit_command.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ def test_commit_command_with_signoff_option(config, mocker: MockFixture):
260260

261261
commands.Commit(config, {"signoff": True})()
262262

263-
commit_mock.assert_called_once_with(ANY, args="-- -s")
263+
commit_mock.assert_called_once_with(ANY, args="-s")
264264
success_mock.assert_called_once()
265265

266266

@@ -283,7 +283,7 @@ def test_commit_command_with_always_signoff_enabled(config, mocker: MockFixture)
283283
config.settings["always_signoff"] = True
284284
commands.Commit(config, {})()
285285

286-
commit_mock.assert_called_once_with(ANY, args="-- -s")
286+
commit_mock.assert_called_once_with(ANY, args="-s")
287287
success_mock.assert_called_once()
288288

289289

0 commit comments

Comments
 (0)