Skip to content

Commit 8847b2d

Browse files
Xiao75896453Lee-W
authored andcommitted
feat(commands): add arg of cz commit to execute git add
1 parent bec05da commit 8847b2d

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

commitizen/cli.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,11 @@
7575
"action": "store_true",
7676
"help": "sign off the commit",
7777
},
78+
{
79+
"name": ["-a", "--add"],
80+
"action": "store_true",
81+
"help": "automatically stage every tracked and un-staged file",
82+
},
7883
],
7984
},
8085
{

commitizen/commands/commit.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ def __call__(self):
6767
dry_run: bool = self.arguments.get("dry_run")
6868
write_message_to_file = self.arguments.get("write_message_to_file")
6969

70+
is_git_add: bool = self.arguments.get("add")
71+
if is_git_add:
72+
c = git.add()
73+
7074
if git.is_staging_clean() and not dry_run:
7175
raise NothingToCommitError("No files added to staging!")
7276

commitizen/git.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,11 @@ def tag(tag: str, annotated: bool = False, signed: bool = False) -> cmd.Command:
9292
return c
9393

9494

95+
def add():
96+
c = cmd.run("git add .")
97+
return c
98+
99+
95100
def commit(
96101
message: str, args: str = "", committer_date: str | None = None
97102
) -> cmd.Command:

0 commit comments

Comments
 (0)