Skip to content

Commit

Permalink
fix(commitizen): Modify the function of the arg a of commit from git …
Browse files Browse the repository at this point in the history
…add all to git add update
  • Loading branch information
Xiao75896453 authored and Lee-W committed Sep 15, 2023
1 parent f0382a6 commit 2177a67
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions commitizen/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
},
],
},
Expand Down
6 changes: 3 additions & 3 deletions commitizen/commands/commit.py
Original file line number Diff line number Diff line change
Expand Up @@ -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!")
Expand Down
4 changes: 2 additions & 2 deletions commitizen/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
2 changes: 1 addition & 1 deletion tests/commands/test_commit_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 2177a67

Please sign in to comment.