Skip to content

feat(commands)!: deprecate '-s' signoff parameter #1221

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 7 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions commitizen/cli.py
Original file line number Diff line number Diff line change
@@ -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",
@@ -162,6 +157,12 @@ def __call__(
"default": 0,
"help": "length limit of the commit message; 0 for no limit",
},
{
"name": ["--"],
"action": "store_true",
"dest": "double_dash",
"help": "Positional arguments separator (recommended)",
},
],
},
{
15 changes: 5 additions & 10 deletions commitizen/commands/commit.py
Original file line number Diff line number Diff line change
@@ -110,17 +110,12 @@ def __call__(self):
if dry_run:
raise DryRunExit()

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

if signoff:
out.warn(
"signoff mechanic is deprecated, please use `cz commit -- -s` instead."
)
extra_args = self.arguments.get("extra_cli_args", "--") + " -s"
else:
extra_args = self.arguments.get("extra_cli_args", "")
extra_args = self.arguments.get("extra_cli_args", "")

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

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

5 changes: 1 addition & 4 deletions docs/commands/commit.md
Original file line number Diff line number Diff line change
@@ -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

4 changes: 2 additions & 2 deletions docs/getting_started.md
Original file line number Diff line number Diff line change
@@ -51,13 +51,13 @@ cz c
Run in the terminal

```bash
cz commit --signoff
cz commit -- --signoff
```

or the shortcut

```bash
cz commit -s
cz commit -- -s
```

### Get project version
38 changes: 19 additions & 19 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 9 additions & 6 deletions tests/commands/test_commit_command.py
Original file line number Diff line number Diff line change
@@ -243,7 +243,7 @@ def test_commit_command_with_invalid_write_message_to_file_option(


@pytest.mark.usefixtures("staging_is_clean")
def test_commit_command_with_signoff_option(config, mocker: MockFixture):
def test_commit_command_with_always_signoff_enabled(config, mocker: MockFixture):
prompt_mock = mocker.patch("questionary.prompt")
prompt_mock.return_value = {
"prefix": "feat",
@@ -258,14 +258,17 @@ def test_commit_command_with_signoff_option(config, mocker: MockFixture):
commit_mock.return_value = cmd.Command("success", "", b"", b"", 0)
success_mock = mocker.patch("commitizen.out.success")

commands.Commit(config, {"signoff": True})()
config.settings["always_signoff"] = True
commands.Commit(config, {})()

commit_mock.assert_called_once_with(ANY, args="-- -s")
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):
def test_commit_command_with_gpgsign_and_always_signoff_enabled(
config, mocker: MockFixture
):
prompt_mock = mocker.patch("questionary.prompt")
prompt_mock.return_value = {
"prefix": "feat",
@@ -281,9 +284,9 @@ def test_commit_command_with_always_signoff_enabled(config, mocker: MockFixture)
success_mock = mocker.patch("commitizen.out.success")

config.settings["always_signoff"] = True
commands.Commit(config, {})()
commands.Commit(config, {"extra_cli_args": "-S"})()

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


Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
usage: cz commit [-h] [--retry] [--no-retry] [--dry-run]
[--write-message-to-file FILE_PATH] [-s] [-a]
[-l MESSAGE_LENGTH_LIMIT]
[--write-message-to-file FILE_PATH] [-a]
[-l MESSAGE_LENGTH_LIMIT] [--]

create new commit

@@ -12,9 +12,9 @@ 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.
-l, --message-length-limit MESSAGE_LENGTH_LIMIT
length limit of the commit message; 0 for no limit
-- Positional arguments separator (recommended)
9 changes: 8 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
@@ -35,12 +35,19 @@ def git_sandbox(monkeypatch: pytest.MonkeyPatch, tmp_path: Path):
gitconfig = tmp_path / ".git" / "config"
if not gitconfig.parent.exists():
gitconfig.parent.mkdir()

monkeypatch.setenv("GIT_CONFIG_GLOBAL", str(gitconfig))

r = cmd.run(f"git config --file {gitconfig} user.name {SIGNER}")
assert r.return_code == 0, r.err
r = cmd.run(f"git config --file {gitconfig} user.email {SIGNER_MAIL}")
assert r.return_code == 0, r.err
cmd.run("git config --global init.defaultBranch master")

r = cmd.run(f"git config --file {gitconfig} safe.directory '*'")
assert r.return_code == 0, r.err

r = cmd.run("git config --global init.defaultBranch master")
assert r.return_code == 0, r.err


@pytest.fixture