GeezerVison is showing github.com — refactor(extra_args): Fixed broken code due to rebase and finalized t… · commitizen-tools/commitizen@1a0ad6c
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: commitizen/commands/commit.py +5-3Lines changed: 5 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -98,10 +98,12 @@ def __call__(self): | 98 | 98 | ) | 99 | 99 |
| 100 | 100 | if signoff: | 101 | | - out.warn("signoff mechanic is deprecated, please use `cz commit -- -s` instead.") | 102 | | - extra_args = "-s " + self.arguments.get("extra_cli_args") | | 101 | + out.warn( | | 102 | + "signoff mechanic is deprecated, please use `cz commit -- -s` instead." | | 103 | + ) | | 104 | + extra_args = self.arguments.get("extra_cli_args", "--") + " -s" | 103 | 105 | else: | 104 | | - extra_args = self.arguments.get("extra_cli_args") | | 106 | + extra_args = self.arguments.get("extra_cli_args", "") | 105 | 107 |
| 106 | 108 | c = git.commit(m, extra_args=extra_args) | 107 | 109 |
| |
Collapse file Copy file name to clipboardExpand all lines: commitizen/git.py +5-2Lines changed: 5 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -98,13 +98,16 @@ def add(args: str = "") -> cmd.Command: | 98 | 98 |
| 99 | 99 |
| 100 | 100 | def commit( | 101 | | - message: str, args: str = "", extra_args: str = "", committer_date: str | None = None | | 101 | + message: str, | | 102 | + args: str = "", | | 103 | + extra_args: str = "", | | 104 | + committer_date: str | None = None, | 102 | 105 | ) -> cmd.Command: | 103 | 106 | f = NamedTemporaryFile("wb", delete=False) | 104 | 107 | f.write(message.encode("utf-8")) | 105 | 108 | f.close() | 106 | 109 |
| 107 | | - command = cmd.run(f"git commit {args} {extra_args} -F {f.name}") | | 110 | + command = f"git commit {args} {extra_args} -F {f.name}" | 108 | 111 |
| 109 | 112 | if committer_date and os.name == "nt": # pragma: no cover | 110 | 113 | # Using `cmd /v /c "{command}"` sets environment variables only for that command | |
Collapse file Copy file name to clipboardExpand all lines: docs/bump.md +1-1Lines changed: 1 addition & 1 deletion - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -323,7 +323,7 @@ These are used in: | 323 | 323 |
| 324 | 324 | * `cz bump`: Find previous release tag (exact match) and generate new tag. | 325 | 325 | * Find previous release tags in `cz changelog`. | 326 | | - * If `--incremental`: Using latest version found in the changelog, scan existing Git tags with 89\% similarity match. | | 326 | + * If `--incremental`: Using latest version found in the changelog, scan existing Git tags with 89\% similarity match. | 327 | 327 | * `--rev-range` is converted to Git tag names with `tag_format` before searching Git history. | 328 | 328 | * If the `scm` `version_provider` is used, it uses different regexes to find the previous version tags: | 329 | 329 | * If `tag_format` is set to `$version` (default): `VersionProtocol.parser` (allows `v` prefix) | |
Collapse file Copy file name to clipboardExpand all lines: docs/commit.md +1-1Lines changed: 1 addition & 1 deletion - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -28,4 +28,4 @@ For example, using the `-S` option on `git commit` to sign a commit is now commi | 28 | 28 |
| 29 | 29 | !!! note | 30 | 30 | Deprecation warning: A commit can be signed off using `cz commit --signoff` or the shortcut `cz commit -s`. | 31 | | - This syntax is now deprecated in favor of the new `cz commit -- -s` syntax. | | 31 | + This syntax is now deprecated in favor of the new `cz commit -- -s` syntax. |
Collapse file Copy file name to clipboardExpand all lines: tests/commands/test_commit_command.py +23-3Lines changed: 23 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -88,7 +88,7 @@ def test_commit_retry_works(config, mocker: MockFixture): | 88 | 88 |
| 89 | 89 | commands.Commit(config, {"retry": True})() | 90 | 90 |
| 91 | | - commit_mock.assert_called_with("feat: user created\n\ncloses #21") | | 91 | + commit_mock.assert_called_with("feat: user created\n\ncloses #21", extra_args="") | 92 | 92 | prompt_mock.assert_called_once() | 93 | 93 | success_mock.assert_called_once() | 94 | 94 | assert not os.path.isfile(temp_file) | @@ -174,7 +174,7 @@ def test_commit_command_with_signoff_option(config, mocker: MockFixture): | 174 | 174 |
| 175 | 175 | commands.Commit(config, {"signoff": True})() | 176 | 176 |
| 177 | | - commit_mock.assert_called_once_with(ANY, "-s") | | 177 | + commit_mock.assert_called_once_with(ANY, extra_args="-- -s") | 178 | 178 | success_mock.assert_called_once() | 179 | 179 |
| 180 | 180 |
| @@ -197,7 +197,7 @@ def test_commit_command_with_always_signoff_enabled(config, mocker: MockFixture) | 197 | 197 | config.settings["always_signoff"] = True | 198 | 198 | commands.Commit(config, {})() | 199 | 199 |
| 200 | | - commit_mock.assert_called_once_with(ANY, "-s") | | 200 | + commit_mock.assert_called_once_with(ANY, extra_args="-- -s") | 201 | 201 | success_mock.assert_called_once() | 202 | 202 |
| 203 | 203 |
| @@ -276,3 +276,23 @@ def test_commit_command_with_all_option(config, mocker: MockFixture): | 276 | 276 | commands.Commit(config, {"all": True})() | 277 | 277 | add_mock.assert_called() | 278 | 278 | success_mock.assert_called_once() | | 279 | + | | 280 | + | | 281 | +@pytest.mark.usefixtures("staging_is_clean") | | 282 | +def test_commit_command_with_extra_args(config, mocker: MockFixture): | | 283 | + prompt_mock = mocker.patch("questionary.prompt") | | 284 | + prompt_mock.return_value = { | | 285 | + "prefix": "feat", | | 286 | + "subject": "user created", | | 287 | + "scope": "", | | 288 | + "is_breaking_change": False, | | 289 | + "body": "", | | 290 | + "footer": "", | | 291 | + } | | 292 | + | | 293 | + commit_mock = mocker.patch("commitizen.git.commit") | | 294 | + commit_mock.return_value = cmd.Command("success", "", b"", b"", 0) | | 295 | + success_mock = mocker.patch("commitizen.out.success") | | 296 | + commands.Commit(config, {"extra_cli_args": "-- -extra-args1 -extra-arg2"})() | | 297 | + commit_mock.assert_called_once_with(ANY, extra_args="-- -extra-args1 -extra-arg2") | | 298 | + success_mock.assert_called_once() |
Collapse file Copy file name to clipboardExpand all lines: tests/test_cli.py +7-3Lines changed: 7 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 8 | 8 |
| 9 | 9 | from commitizen import cli | 10 | 10 | from commitizen.exceptions import ( | 11 | | - ExpectedExit, NoCommandFoundError, NotAGitProjectError, InvalidCommandArgumentError, NothingToCommitError | | 11 | + ExpectedExit, | | 12 | + NoCommandFoundError, | | 13 | + NotAGitProjectError, | | 14 | + InvalidCommandArgumentError, | 12 | 15 | ) | 13 | 16 |
| 14 | 17 |
| @@ -166,5 +169,6 @@ def test_unknown_args_before_double_dash_raises(mocker: MockFixture): | 166 | 169 | mocker.patch.object(sys, "argv", testargs) | 167 | 170 | with pytest.raises(InvalidCommandArgumentError) as excinfo: | 168 | 171 | cli.main() | 169 | | - assert "Invalid commitizen arguments were found before -- separator" in str(excinfo.value) | 170 | | - | | 172 | + assert "Invalid commitizen arguments were found before -- separator" in str( | | 173 | + excinfo.value | | 174 | + ) |
Collapse file Copy file name to clipboardExpand all lines: tests/test_command_commit.py -22Lines changed: 0 additions & 22 deletions
|