Skip to content

Commit 5efe4cc

Browse files
committed
feat(git): add is_staging_clean to check if there is any file in git staging
1 parent 1f6ffb0 commit 5efe4cc

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

commitizen/git.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,10 @@ def get_commits(start: str, end: str = "HEAD", from_beginning: bool = False) ->
3333
def tag_exist(tag: str) -> bool:
3434
c = cmd.run(f"git tag --list {tag}")
3535
return tag in c.out
36+
37+
38+
def is_staging_clean() -> bool:
39+
"""Check if staing is clean"""
40+
c = cmd.run("git diff --no-ext-diff --name-only")
41+
c_cached = cmd.run("git diff --no-ext-diff --cached --name-only")
42+
return not (bool(c.out) or bool(c_cached.out))

0 commit comments

Comments
 (0)