Skip to content

Commit dfa64ea

Browse files
12rambauLee-W
authored andcommitted
feat: draft of the --empty parameter
1 parent 5236aba commit dfa64ea

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

commitizen/cli.py

+6
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,12 @@ def __call__(
336336
"help": "Add additional build-metadata to the version-number",
337337
"default": None,
338338
},
339+
{
340+
"name": ["--empty"],
341+
"default": False,
342+
"help": "bump tags without new commits",
343+
"action": "store_true",
344+
},
339345
],
340346
},
341347
{

commitizen/commands/bump.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ def __call__(self) -> None: # noqa: C901
159159
manual_version = self.arguments["manual_version"]
160160
build_metadata = self.arguments["build_metadata"]
161161
increment_mode: str = self.arguments["increment_mode"]
162+
is_empty: bool | None = self.arguments["empty"]
162163

163164
if manual_version:
164165
if increment:
@@ -231,7 +232,7 @@ def __call__(self) -> None: # noqa: C901
231232

232233
# No commits, there is no need to create an empty tag.
233234
# Unless we previously had a prerelease.
234-
if not commits and not current_version.is_prerelease:
235+
if not commits and not current_version.is_prerelease and not is_empty:
235236
raise NoCommitsFoundError(
236237
"[NO_COMMITS_FOUND]\n" "No new commits found."
237238
)
@@ -247,6 +248,10 @@ def __call__(self) -> None: # noqa: C901
247248
"To avoid this error, manually specify the type of increment with `--increment`"
248249
)
249250

251+
# we create an empty PATCH increment for empty tag
252+
if increment is None and is_empty:
253+
increment = "PATCH"
254+
250255
new_version = current_version.bump(
251256
increment,
252257
prerelease=prerelease,

0 commit comments

Comments
 (0)