feat: add --allow-no-commit option by 12rambau · Pull Request #723 · commitizen-tools/commitizen · GitHub
Skip to content
Merged
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
6 changes: 6 additions & 0 deletions commitizen/cli.py
11 changes: 10 additions & 1 deletion commitizen/commands/bump.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ def __call__(self) -> None: # noqa: C901
build_metadata = self.arguments["build_metadata"]
increment_mode: str = self.arguments["increment_mode"]
get_next: bool = self.arguments["get_next"]
allow_no_commit: bool | None = self.arguments["allow_no_commit"]

if manual_version:
if increment:
Expand Down Expand Up @@ -250,7 +251,11 @@ def __call__(self) -> None: # noqa: C901

# No commits, there is no need to create an empty tag.
# Unless we previously had a prerelease.
if not commits and not current_version.is_prerelease:
if (
not commits
and not current_version.is_prerelease
and not allow_no_commit
):
raise NoCommitsFoundError(
"[NO_COMMITS_FOUND]\nNo new commits found."
)
Expand All @@ -266,6 +271,10 @@ def __call__(self) -> None: # noqa: C901
"To avoid this error, manually specify the type of increment with `--increment`"
)

# we create an empty PATCH increment for empty tag
if increment is None and allow_no_commit:
increment = "PATCH"

new_version = current_version.bump(
increment,
prerelease=prerelease,
Expand Down
36 changes: 24 additions & 12 deletions docs/commands/bump.md
Loading