Movatterモバイル変換


[0]ホーム

URL:


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

Commit26be522

Browse files
AdrianDCLee-W
authored andcommitted
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 parentd017869 commit26be522

File tree

2 files changed

+30
-5
lines changed

2 files changed

+30
-5
lines changed

‎commitizen/commands/commit.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,13 +138,13 @@ def __call__(self):
138138
self.arguments.get("signoff")orself.config.settings["always_signoff"]
139139
)
140140

141+
extra_args=self.arguments.get("extra_cli_args","")
142+
141143
ifsignoff:
142144
out.warn(
143145
"signoff mechanic is deprecated, please use `cz commit -- -s` instead."
144146
)
145-
extra_args=self.arguments.get("extra_cli_args","--")+" -s"
146-
else:
147-
extra_args=self.arguments.get("extra_cli_args","")
147+
extra_args=f"{extra_args} -s".strip()
148148

149149
c=git.commit(m,args=extra_args)
150150

‎tests/commands/test_commit_command.py‎

Lines changed: 27 additions & 2 deletions
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,32 @@ 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")
287+
success_mock.assert_called_once()
288+
289+
290+
@pytest.mark.usefixtures("staging_is_clean")
291+
deftest_commit_command_with_gpgsign_and_always_signoff_enabled(
292+
config,mocker:MockFixture
293+
):
294+
prompt_mock=mocker.patch("questionary.prompt")
295+
prompt_mock.return_value= {
296+
"prefix":"feat",
297+
"subject":"user created",
298+
"scope":"",
299+
"is_breaking_change":False,
300+
"body":"",
301+
"footer":"",
302+
}
303+
304+
commit_mock=mocker.patch("commitizen.git.commit")
305+
commit_mock.return_value=cmd.Command("success","",b"",b"",0)
306+
success_mock=mocker.patch("commitizen.out.success")
307+
308+
config.settings["always_signoff"]=True
309+
commands.Commit(config, {"extra_cli_args":"-S"})()
310+
311+
commit_mock.assert_called_once_with(ANY,args="-S -s")
287312
success_mock.assert_called_once()
288313

289314

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp