Skip to content

Commit

Permalink
refactor(git.py): Removed 'extra_args' from git.commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Scrocky authored and Lee-W committed Oct 17, 2023
1 parent 82879ab commit 12b214e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion commitizen/commands/commit.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def __call__(self):
else:
extra_args = self.arguments.get("extra_cli_args", "")

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

if c.return_code != 0:
out.error(c.err)
Expand Down
3 changes: 1 addition & 2 deletions commitizen/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,13 @@ def add(args: str = "") -> cmd.Command:
def commit(
message: str,
args: str = "",
extra_args: str = "",
committer_date: str | None = None,
) -> cmd.Command:
f = NamedTemporaryFile("wb", delete=False)
f.write(message.encode("utf-8"))
f.close()

command = f"git commit {args} {extra_args} -F {f.name}"
command = f"git commit {args} -F {f.name}"

if committer_date and os.name == "nt": # pragma: no cover
# Using `cmd /v /c "{command}"` sets environment variables only for that command
Expand Down
8 changes: 4 additions & 4 deletions tests/commands/test_commit_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def test_commit_retry_works(config, mocker: MockFixture):

commands.Commit(config, {"retry": True})()

commit_mock.assert_called_with("feat: user created\n\ncloses #21", extra_args="")
commit_mock.assert_called_with("feat: user created\n\ncloses #21", args="")
prompt_mock.assert_called_once()
success_mock.assert_called_once()
assert not os.path.isfile(temp_file)
Expand Down Expand Up @@ -174,7 +174,7 @@ def test_commit_command_with_signoff_option(config, mocker: MockFixture):

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

commit_mock.assert_called_once_with(ANY, extra_args="-- -s")
commit_mock.assert_called_once_with(ANY, args="-- -s")
success_mock.assert_called_once()


Expand All @@ -197,7 +197,7 @@ def test_commit_command_with_always_signoff_enabled(config, mocker: MockFixture)
config.settings["always_signoff"] = True
commands.Commit(config, {})()

commit_mock.assert_called_once_with(ANY, extra_args="-- -s")
commit_mock.assert_called_once_with(ANY, args="-- -s")
success_mock.assert_called_once()


Expand Down Expand Up @@ -294,5 +294,5 @@ def test_commit_command_with_extra_args(config, mocker: MockFixture):
commit_mock.return_value = cmd.Command("success", "", b"", b"", 0)
success_mock = mocker.patch("commitizen.out.success")
commands.Commit(config, {"extra_cli_args": "-- -extra-args1 -extra-arg2"})()
commit_mock.assert_called_once_with(ANY, extra_args="-- -extra-args1 -extra-arg2")
commit_mock.assert_called_once_with(ANY, args="-- -extra-args1 -extra-arg2")
success_mock.assert_called_once()

0 comments on commit 12b214e

Please sign in to comment.