Skip to content

Commit cd69c9a

Browse files
12rambauLee-W
authored andcommitted
feat: draft of the --empty parameter
1 parent 7eafdfa commit cd69c9a

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

commitizen/cli.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,12 @@ def __call__(
342342
"help": "Add additional build-metadata to the version-number",
343343
"default": None,
344344
},
345+
{
346+
"name": ["--empty"],
347+
"default": False,
348+
"help": "bump tags without new commits",
349+
"action": "store_true",
350+
},
345351
],
346352
},
347353
{

commitizen/commands/bump.py

Lines changed: 6 additions & 1 deletion
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)