From fec12e28c2adc03ddf0e0d19906b2b7de89fa387 Mon Sep 17 00:00:00 2001 From: Xiao75896453 <47842610+Xiao75896453@users.noreply.github.com> Date: Sun, 20 Aug 2023 16:13:01 +0800 Subject: [PATCH 1/7] feat(commands): add arg of cz commit to execute git add --- commitizen/cli.py | 5 +++++ commitizen/commands/commit.py | 4 ++++ commitizen/git.py | 5 +++++ 3 files changed, 14 insertions(+) diff --git a/commitizen/cli.py b/commitizen/cli.py index 472ef2b270..db48ad3218 100644 --- a/commitizen/cli.py +++ b/commitizen/cli.py @@ -75,6 +75,11 @@ "action": "store_true", "help": "sign off the commit", }, + { + "name": ["-a", "--add"], + "action": "store_true", + "help": "automatically stage every tracked and un-staged file", + }, ], }, { diff --git a/commitizen/commands/commit.py b/commitizen/commands/commit.py index 913526f893..dff78dd3b2 100644 --- a/commitizen/commands/commit.py +++ b/commitizen/commands/commit.py @@ -67,6 +67,10 @@ def __call__(self): dry_run: bool = self.arguments.get("dry_run") write_message_to_file = self.arguments.get("write_message_to_file") + is_git_add: bool = self.arguments.get("add") + if is_git_add: + c = git.add() + if git.is_staging_clean() and not dry_run: raise NothingToCommitError("No files added to staging!") diff --git a/commitizen/git.py b/commitizen/git.py index adfe494383..555a356c33 100644 --- a/commitizen/git.py +++ b/commitizen/git.py @@ -92,6 +92,11 @@ def tag(tag: str, annotated: bool = False, signed: bool = False) -> cmd.Command: return c +def add(): + c = cmd.run("git add .") + return c + + def commit( message: str, args: str = "", committer_date: str | None = None ) -> cmd.Command: From 5fd0b3227b149616ecbf2ee5f0c2aaaad8f6ace6 Mon Sep 17 00:00:00 2001 From: Xiao75896453 <47842610+Xiao75896453@users.noreply.github.com> Date: Sun, 20 Aug 2023 16:45:35 +0800 Subject: [PATCH 2/7] test(commands): test command cz commit with arg -a --- tests/commands/test_commit_command.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tests/commands/test_commit_command.py b/tests/commands/test_commit_command.py index 29840bb6a1..38b00a341a 100644 --- a/tests/commands/test_commit_command.py +++ b/tests/commands/test_commit_command.py @@ -255,3 +255,24 @@ def test_commit_in_non_git_project(tmpdir, config): with tmpdir.as_cwd(): with pytest.raises(NotAGitProjectError): commands.Commit(config, {}) + + +@pytest.mark.usefixtures("staging_is_clean") +def test_commit_command_with_add_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") + add_mock = mocker.patch("commitizen.git.add") + commands.Commit(config, {"add": True})() + add_mock.assert_called() + success_mock.assert_called_once() From f0382a6c960ccdd38b72d143bd96f1ae554c4b9a Mon Sep 17 00:00:00 2001 From: Xiao75896453 <47842610+Xiao75896453@users.noreply.github.com> Date: Sun, 20 Aug 2023 16:47:46 +0800 Subject: [PATCH 3/7] refactor(commitizen): add return type hint of git add function --- commitizen/git.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commitizen/git.py b/commitizen/git.py index 555a356c33..86f49a06bd 100644 --- a/commitizen/git.py +++ b/commitizen/git.py @@ -92,7 +92,7 @@ def tag(tag: str, annotated: bool = False, signed: bool = False) -> cmd.Command: return c -def add(): +def add() -> cmd.Command: c = cmd.run("git add .") return c From 2177a67da392b354ada88d6adb75a4f3957b5318 Mon Sep 17 00:00:00 2001 From: Xiao75896453 <47842610+Xiao75896453@users.noreply.github.com> Date: Mon, 21 Aug 2023 19:29:52 +0800 Subject: [PATCH 4/7] fix(commitizen): Modify the function of the arg a of commit from git add all to git add update --- commitizen/cli.py | 4 ++-- commitizen/commands/commit.py | 6 +++--- commitizen/git.py | 4 ++-- tests/commands/test_commit_command.py | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/commitizen/cli.py b/commitizen/cli.py index db48ad3218..7f4d4893c0 100644 --- a/commitizen/cli.py +++ b/commitizen/cli.py @@ -76,9 +76,9 @@ "help": "sign off the commit", }, { - "name": ["-a", "--add"], + "name": ["-a", "--all"], "action": "store_true", - "help": "automatically stage every tracked and un-staged file", + "help": "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.", }, ], }, diff --git a/commitizen/commands/commit.py b/commitizen/commands/commit.py index dff78dd3b2..39cab33b5c 100644 --- a/commitizen/commands/commit.py +++ b/commitizen/commands/commit.py @@ -67,9 +67,9 @@ def __call__(self): dry_run: bool = self.arguments.get("dry_run") write_message_to_file = self.arguments.get("write_message_to_file") - is_git_add: bool = self.arguments.get("add") - if is_git_add: - c = git.add() + is_all: bool = self.arguments.get("all") + if is_all: + c = git.add("-u") if git.is_staging_clean() and not dry_run: raise NothingToCommitError("No files added to staging!") diff --git a/commitizen/git.py b/commitizen/git.py index 86f49a06bd..67652b9516 100644 --- a/commitizen/git.py +++ b/commitizen/git.py @@ -92,8 +92,8 @@ def tag(tag: str, annotated: bool = False, signed: bool = False) -> cmd.Command: return c -def add() -> cmd.Command: - c = cmd.run("git add .") +def add(args: str = "") -> cmd.Command: + c = cmd.run(f"git add {args}") return c diff --git a/tests/commands/test_commit_command.py b/tests/commands/test_commit_command.py index 38b00a341a..c386c97751 100644 --- a/tests/commands/test_commit_command.py +++ b/tests/commands/test_commit_command.py @@ -258,7 +258,7 @@ def test_commit_in_non_git_project(tmpdir, config): @pytest.mark.usefixtures("staging_is_clean") -def test_commit_command_with_add_option(config, mocker: MockFixture): +def test_commit_command_with_all_option(config, mocker: MockFixture): prompt_mock = mocker.patch("questionary.prompt") prompt_mock.return_value = { "prefix": "feat", From ea9193364e81ff0bcd137033c4611f36ca2937ab Mon Sep 17 00:00:00 2001 From: Xiao75896453 <47842610+Xiao75896453@users.noreply.github.com> Date: Mon, 21 Aug 2023 19:37:44 +0800 Subject: [PATCH 5/7] fix(tests): modify the arg of commit from add to all --- tests/commands/test_commit_command.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/commands/test_commit_command.py b/tests/commands/test_commit_command.py index c386c97751..b48ac9d0ed 100644 --- a/tests/commands/test_commit_command.py +++ b/tests/commands/test_commit_command.py @@ -273,6 +273,6 @@ def test_commit_command_with_all_option(config, mocker: MockFixture): commit_mock.return_value = cmd.Command("success", "", b"", b"", 0) success_mock = mocker.patch("commitizen.out.success") add_mock = mocker.patch("commitizen.git.add") - commands.Commit(config, {"add": True})() + commands.Commit(config, {"all": True})() add_mock.assert_called() success_mock.assert_called_once() From 8540939dab59442954923b5d0c72c136a76efe3a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 13 Sep 2023 01:24:42 +0000 Subject: [PATCH 6/7] build(deps-dev): bump ruff from 0.0.287 to 0.0.289 Bumps [ruff](https://github.com/astral-sh/ruff) from 0.0.287 to 0.0.289. - [Release notes](https://github.com/astral-sh/ruff/releases) - [Changelog](https://github.com/astral-sh/ruff/blob/main/BREAKING_CHANGES.md) - [Commits](https://github.com/astral-sh/ruff/compare/v0.0.287...v0.0.289) --- updated-dependencies: - dependency-name: ruff dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- poetry.lock | 38 +++++++++++++++++++------------------- pyproject.toml | 2 +- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/poetry.lock b/poetry.lock index a3bd4cddd0..b36ad3a474 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1347,28 +1347,28 @@ use-chardet-on-py3 = ["chardet (>=3.0.2,<6)"] [[package]] name = "ruff" -version = "0.0.287" +version = "0.0.289" description = "An extremely fast Python linter, written in Rust." optional = false python-versions = ">=3.7" files = [ - {file = "ruff-0.0.287-py3-none-macosx_10_7_x86_64.whl", hash = "sha256:1e0f9ee4c3191444eefeda97d7084721d9b8e29017f67997a20c153457f2eafd"}, - {file = "ruff-0.0.287-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl", hash = "sha256:e9843e5704d4fb44e1a8161b0d31c1a38819723f0942639dfeb53d553be9bfb5"}, - {file = "ruff-0.0.287-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:8ca1ed11d759a29695aed2bfc7f914b39bcadfe2ef08d98ff69c873f639ad3a8"}, - {file = "ruff-0.0.287-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:1cf4d5ad3073af10f186ea22ce24bc5a8afa46151f6896f35c586e40148ba20b"}, - {file = "ruff-0.0.287-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:66d9d58bcb29afd72d2afe67120afcc7d240efc69a235853813ad556443dc922"}, - {file = "ruff-0.0.287-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:06ac5df7dd3ba8bf83bba1490a72f97f1b9b21c7cbcba8406a09de1a83f36083"}, - {file = "ruff-0.0.287-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:2bfb478e1146a60aa740ab9ebe448b1f9e3c0dfb54be3cc58713310eef059c30"}, - {file = "ruff-0.0.287-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:00d579a011949108c4b4fa04c4f1ee066dab536a9ba94114e8e580c96be2aeb4"}, - {file = "ruff-0.0.287-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d3a810a79b8029cc92d06c36ea1f10be5298d2323d9024e1d21aedbf0a1a13e5"}, - {file = "ruff-0.0.287-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:150007028ad4976ce9a7704f635ead6d0e767f73354ce0137e3e44f3a6c0963b"}, - {file = "ruff-0.0.287-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:a24a280db71b0fa2e0de0312b4aecb8e6d08081d1b0b3c641846a9af8e35b4a7"}, - {file = "ruff-0.0.287-py3-none-musllinux_1_2_i686.whl", hash = "sha256:2918cb7885fa1611d542de1530bea3fbd63762da793751cc8c8d6e4ba234c3d8"}, - {file = "ruff-0.0.287-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:33d7b251afb60bec02a64572b0fd56594b1923ee77585bee1e7e1daf675e7ae7"}, - {file = "ruff-0.0.287-py3-none-win32.whl", hash = "sha256:022f8bed2dcb5e5429339b7c326155e968a06c42825912481e10be15dafb424b"}, - {file = "ruff-0.0.287-py3-none-win_amd64.whl", hash = "sha256:26bd0041d135a883bd6ab3e0b29c42470781fb504cf514e4c17e970e33411d90"}, - {file = "ruff-0.0.287-py3-none-win_arm64.whl", hash = "sha256:44bceb3310ac04f0e59d4851e6227f7b1404f753997c7859192e41dbee9f5c8d"}, - {file = "ruff-0.0.287.tar.gz", hash = "sha256:02dc4f5bf53ef136e459d467f3ce3e04844d509bc46c025a05b018feb37bbc39"}, + {file = "ruff-0.0.289-py3-none-macosx_10_7_x86_64.whl", hash = "sha256:c9a89d748e90c840bac9c37afe90cf13a5bfd460ca02ea93dad9d7bee3af03b4"}, + {file = "ruff-0.0.289-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl", hash = "sha256:7f7396c6ea01ba332a6ad9d47642bac25d16bd2076aaa595b001f58b2f32ff05"}, + {file = "ruff-0.0.289-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:7180de86c8ecd39624dec1699136f941c07e723201b4ce979bec9e7c67b40ad2"}, + {file = "ruff-0.0.289-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:73f37c65508203dd01a539926375a10243769c20d4fcab3fa6359cd3fbfc54b7"}, + {file = "ruff-0.0.289-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:1c14abcd7563b5c80be2dd809eeab20e4aa716bf849860b60a22d87ddf19eb88"}, + {file = "ruff-0.0.289-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:91b6d63b6b46d4707916472c91baa87aa0592e73f62a80ff55efdf6c0668cfd6"}, + {file = "ruff-0.0.289-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:6479b8c4be3c36046c6c92054762b276fa0fddb03f6b9a310fbbf4c4951267fd"}, + {file = "ruff-0.0.289-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:c5424318c254bcb091cb67e140ec9b9f7122074e100b06236f252923fb41e767"}, + {file = "ruff-0.0.289-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:4daa90865796aedcedf0d8897fdd4cd09bf0ddd3504529a4ccf211edcaff3c7d"}, + {file = "ruff-0.0.289-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:8057e8ab0016c13b9419bad119e854f881e687bd96bc5e2d52c8baac0f278a44"}, + {file = "ruff-0.0.289-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:7eebfab2e6a6991908ff1bf82f2dc1e5095fc7e316848e62124526837b445f4d"}, + {file = "ruff-0.0.289-py3-none-musllinux_1_2_i686.whl", hash = "sha256:ebc7af550018001a7fb39ca22cdce20e1a0de4388ea4a007eb5c822f6188c297"}, + {file = "ruff-0.0.289-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:6e4e6eccb753efe760ba354fc8e9f783f6bba71aa9f592756f5bd0d78db898ed"}, + {file = "ruff-0.0.289-py3-none-win32.whl", hash = "sha256:bbb3044f931c09cf17dbe5b339896eece0d6ac10c9a86e172540fcdb1974f2b7"}, + {file = "ruff-0.0.289-py3-none-win_amd64.whl", hash = "sha256:6d043c5456b792be2615a52f16056c3cf6c40506ce1f2d6f9d3083cfcb9eeab6"}, + {file = "ruff-0.0.289-py3-none-win_arm64.whl", hash = "sha256:04a720bcca5e987426bb14ad8b9c6f55e259ea774da1cbeafe71569744cfd20a"}, + {file = "ruff-0.0.289.tar.gz", hash = "sha256:2513f853b0fc42f0339b7ab0d2751b63ce7a50a0032d2689b54b2931b3b866d7"}, ] [[package]] @@ -1744,4 +1744,4 @@ testing = ["big-O", "flake8 (<5)", "jaraco.functools", "jaraco.itertools", "more [metadata] lock-version = "2.0" python-versions = "^3.7" -content-hash = "1f5241984b249f1376f11caab2a866c2c803d6425179ac2d42590b10edd54aed" +content-hash = "923b6fc85eb26ddf23166898abbcede0fe237d42db19781a71b258813295817c" diff --git a/pyproject.toml b/pyproject.toml index 17b10d2bee..3a4b828b85 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -61,7 +61,7 @@ pytest-xdist = "^3.1.0" # code formatter black = "^22.10" # linter -ruff = ">=0.0.275,<0.0.288" +ruff = ">=0.0.275,<0.0.290" pre-commit = "^2.18.0" mypy = "^1.4" types-PyYAML = ">=5.4.3,<7.0.0" From 1d8d14f913e2e493f793e31196c6a349699167b6 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Fri, 15 Sep 2023 10:18:07 +0000 Subject: [PATCH 7/7] =?UTF-8?q?bump:=20version=203.8.2=20=E2=86=92=203.9.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .pre-commit-config.yaml | 2 +- CHANGELOG.md | 15 +++++++++++++++ commitizen/__version__.py | 2 +- pyproject.toml | 4 ++-- 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 65aaef318c..d700f4898e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -46,7 +46,7 @@ repos: exclude: "poetry.lock" - repo: https://github.com/commitizen-tools/commitizen - rev: v3.8.2 # automatically updated by Commitizen + rev: v3.9.0 # automatically updated by Commitizen hooks: - id: commitizen - id: commitizen-branch diff --git a/CHANGELOG.md b/CHANGELOG.md index d5e652ce47..16dee25c36 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,19 @@ +## v3.9.0 (2023-09-15) + +### Feat + +- **commands**: add arg of cz commit to execute git add + +### Fix + +- **tests**: modify the arg of commit from add to all +- **commitizen**: Modify the function of the arg a of commit from git add all to git add update + +### Refactor + +- **commitizen**: add return type hint of git add function + ## v3.8.2 (2023-09-09) ### Refactor diff --git a/commitizen/__version__.py b/commitizen/__version__.py index 2ae7a96321..fcd7ddb9e4 100644 --- a/commitizen/__version__.py +++ b/commitizen/__version__.py @@ -1 +1 @@ -__version__ = "3.8.2" +__version__ = "3.9.0" diff --git a/pyproject.toml b/pyproject.toml index 3a4b828b85..9b44ed2494 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [tool.commitizen] -version = "3.8.2" +version = "3.9.0" tag_format = "v$version" version_files = [ "pyproject.toml:version", @@ -9,7 +9,7 @@ version_files = [ [tool.poetry] name = "commitizen" -version = "3.8.2" +version = "3.9.0" description = "Python commitizen client tool" authors = ["Santiago Fraire "] license = "MIT"