@@ -143,6 +143,7 @@ def _increment_version(
143143 prerelease : bool ,
144144 prerelease_token : str ,
145145 major_on_zero : bool ,
146+ allow_zero_version : bool ,
146147) -> Version :
147148 """
148149 Using the given versions, along with a given `level_bump`, increment to
@@ -158,19 +159,29 @@ def _increment_version(
158159 `latest_full_version_in_history`, correspondingly, is the latest full release which
159160 is in this branch's history.
160161 """
162+ local_vars = list (locals ().items ())
161163 log .debug (
162- "_increment_version: %s" , ", " .join (f"{ k } = { v } " for k , v in locals (). items () )
164+ "_increment_version: %s" , ", " .join (f"{ k } = { v } " for k , v in local_vars )
163165 )
164- if not major_on_zero and latest_version .major == 0 :
165- # if we are a 0.x.y release and have set `major_on_zero`,
166- # breaking changes should increment the minor digit
167- # Correspondingly, we reduce the level that we increment the
168- # version by.
169- log .debug (
170- "reducing version increment due to 0. version and major_on_zero=False"
171- )
166+ if latest_version .major == 0 :
167+ if not allow_zero_version :
168+ # Set up default version to be 1.0.0 if currently 0.x.x which means a commented
169+ # breaking change is not required to bump to 1.0.0
170+ log .debug (
171+ "Bumping major version as 0.x.x versions are disabled because of allow_zero_version=False"
172+ )
173+ level_bump = LevelBump .MAJOR
174+
175+ elif not major_on_zero :
176+ # if we are a 0.x.y release and have set `major_on_zero`,
177+ # breaking changes should increment the minor digit
178+ # Correspondingly, we reduce the level that we increment the
179+ # version by.
180+ log .debug (
181+ "reducing version increment due to 0. version and major_on_zero=False"
182+ )
172183
173- level_bump = min (level_bump , LevelBump .MINOR )
184+ level_bump = min (level_bump , LevelBump .MINOR )
174185
175186 if prerelease :
176187 log .debug ("prerelease=true" )
@@ -261,6 +272,7 @@ def next_version(
261272 commit_parser : CommitParser [ParseResult , ParserOptions ],
262273 prerelease : bool = False ,
263274 major_on_zero : bool = True ,
275+ allow_zero_version : bool = True ,
264276) -> Version :
265277 """
266278 Evaluate the history within `repo`, and based on the tags and commits in the repo
@@ -398,8 +410,9 @@ def next_version(
398410 level_bump = max (parsed_levels , default = LevelBump .NO_RELEASE )
399411 log .info ("The type of the next release release is: %s" , level_bump )
400412 if level_bump is LevelBump .NO_RELEASE :
401- log .info ("No release will be made" )
402- return latest_version
413+ if latest_version .major != 0 or allow_zero_version :
414+ log .info ("No release will be made" )
415+ return latest_version
403416
404417 return _increment_version (
405418 latest_version = latest_version ,
@@ -418,4 +431,5 @@ def next_version(
418431 prerelease = prerelease ,
419432 prerelease_token = translator .prerelease_token ,
420433 major_on_zero = major_on_zero ,
434+ allow_zero_version = allow_zero_version ,
421435 )
0 commit comments