fix(bump): skip commit step when there are no files to commit by bearomorphism · Pull Request #1969 · commitizen-tools/commitizen · GitHub
Skip to content
Open
Show file tree
Hide file tree
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
49 changes: 33 additions & 16 deletions commitizen/commands/bump.py
12 changes: 12 additions & 0 deletions commitizen/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,18 @@ def is_staging_clean() -> bool:
return not bool(c.out)


def has_pending_changes() -> bool:
"""Check whether there are any tracked-file changes for ``git commit -a`` to commit.

Returns ``True`` if there are staged or unstaged modifications to tracked
files, ``False`` if the working tree is clean for tracked files. Untracked
files are intentionally ignored — they would be ignored by ``git commit -a``
too.
"""
c = cmd.run(["git", "status", "--porcelain", "--untracked-files=no"])
return bool(c.out.strip())


def is_git_project() -> bool:
c = cmd.run(["git", "rev-parse", "--is-inside-work-tree"])
return c.out.strip() == "true"
Expand Down
71 changes: 71 additions & 0 deletions tests/commands/test_bump_command.py
Loading