Skip to content

Commit

Permalink
feat(commands)!: deprecate '-s' signoff parameter
Browse files Browse the repository at this point in the history
Signed-off-by: Adrian DC <[email protected]>
  • Loading branch information
AdrianDC committed Aug 25, 2024
1 parent d211348 commit 70b6708
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 39 deletions.
5 changes: 0 additions & 5 deletions commitizen/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,6 @@ def __call__(
"metavar": "FILE_PATH",
"help": "write message to file before committing (can be combined with --dry-run)",
},
{
"name": ["-s", "--signoff"],
"action": "store_true",
"help": "sign off the commit",
},
{
"name": ["-a", "--all"],
"action": "store_true",
Expand Down
8 changes: 1 addition & 7 deletions commitizen/commands/commit.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,16 +111,10 @@ def __call__(self):
raise DryRunExit()

always_signoff: bool = self.config.settings["always_signoff"]
signoff: bool = self.arguments.get("signoff")

extra_args = self.arguments.get("extra_cli_args", "")

if signoff:
out.warn(
"signoff mechanic is deprecated, please use `cz commit -- -s` instead."
)

if always_signoff or signoff:
if always_signoff:
extra_args = f"{extra_args} -s".strip()

c = git.commit(m, args=extra_args)
Expand Down
5 changes: 1 addition & 4 deletions docs/commands/commit.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,8 @@ cz commit <commitizen-args> -- <git-cli-args>

# e.g., cz commit --dry-run -- -a -S
```
For example, using the `-S` option on `git commit` to sign a commit is now commitizen compatible: `cz c -- -S`

!!! note
Deprecation warning: A commit can be signed off using `cz commit --signoff` or the shortcut `cz commit -s`.
This syntax is now deprecated in favor of the new `cz commit -- -s` syntax.
For example, using the `-S` option on `git commit` to sign a commit is now commitizen compatible: `cz c -- -S`

### Retry

Expand Down
22 changes: 0 additions & 22 deletions tests/commands/test_commit_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,28 +242,6 @@ def test_commit_command_with_invalid_write_message_to_file_option(
commit_cmd()


@pytest.mark.usefixtures("staging_is_clean")
def test_commit_command_with_signoff_option(config, mocker: MockFixture):
prompt_mock = mocker.patch("questionary.prompt")
prompt_mock.return_value = {
"prefix": "feat",
"subject": "user created",
"scope": "",
"is_breaking_change": False,
"body": "",
"footer": "",
}

commit_mock = mocker.patch("commitizen.git.commit")
commit_mock.return_value = cmd.Command("success", "", b"", b"", 0)
success_mock = mocker.patch("commitizen.out.success")

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

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


@pytest.mark.usefixtures("staging_is_clean")
def test_commit_command_with_always_signoff_enabled(config, mocker: MockFixture):
prompt_mock = mocker.patch("questionary.prompt")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ options:
--write-message-to-file FILE_PATH
write message to file before committing (can be
combined with --dry-run)
-s, --signoff sign off the commit
-a, --all Tell the command to automatically stage files that
have been modified and deleted, but new files you have
not told Git about are not affected.
Expand Down

0 comments on commit 70b6708

Please sign in to comment.