mirror of
https://github.com/TECHNOFAB11/bumpver.git
synced 2025-12-12 14:30:09 +01:00
implement INC0 and INC1 parts
This commit is contained in:
parent
f92c7347ae
commit
d23689634c
7 changed files with 62 additions and 24 deletions
|
|
@ -86,6 +86,8 @@ PART_PATTERNS = {
|
|||
'RELEASE': r"preview|final|alpha|beta|post|rc",
|
||||
'PYTAG' : r"post|rc|a|b",
|
||||
'NUM' : r"[0-9]+",
|
||||
'INC0' : r"[0-9]+",
|
||||
'INC1' : r"[1-9][0-9]*",
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -111,6 +113,8 @@ PATTERN_PART_FIELDS = {
|
|||
'RELEASE': 'tag',
|
||||
'PYTAG' : 'pytag',
|
||||
'NUM' : 'num',
|
||||
'INC0' : 'inc0',
|
||||
'INC1' : 'inc1',
|
||||
'WW' : 'week_w',
|
||||
'0W' : 'week_w',
|
||||
'UU' : 'week_u',
|
||||
|
|
@ -183,7 +187,10 @@ def _fmt_0v(week_v: FieldValue) -> str:
|
|||
return "{0:02}".format(int(week_v))
|
||||
|
||||
|
||||
PART_FORMATS: typ.Dict[str, typ.Callable[[FieldValue], str]] = {
|
||||
FormatterFunc = typ.Callable[[FieldValue], str]
|
||||
|
||||
|
||||
PART_FORMATS: typ.Dict[str, FormatterFunc] = {
|
||||
'YYYY' : _fmt_num,
|
||||
'YY' : _fmt_yy,
|
||||
'0Y' : _fmt_0y,
|
||||
|
|
@ -205,6 +212,8 @@ PART_FORMATS: typ.Dict[str, typ.Callable[[FieldValue], str]] = {
|
|||
'RELEASE': _fmt_num,
|
||||
'PYTAG' : _fmt_num,
|
||||
'NUM' : _fmt_num,
|
||||
'INC0' : _fmt_num,
|
||||
'INC1' : _fmt_num,
|
||||
'WW' : _fmt_num,
|
||||
'0W' : _fmt_0w,
|
||||
'UU' : _fmt_num,
|
||||
|
|
|
|||
|
|
@ -201,6 +201,8 @@ def _parse_version_info(field_values: FieldValues) -> version.V2VersionInfo:
|
|||
patch = int(fvals.get('patch') or 0)
|
||||
num = int(fvals.get('num' ) or 0)
|
||||
bid = fvals['bid'] if 'bid' in fvals else "1000"
|
||||
inc0 = int(fvals.get('inc0') or 0)
|
||||
inc1 = int(fvals.get('inc1') or 1)
|
||||
|
||||
vinfo = version.V2VersionInfo(
|
||||
year_y=year_y,
|
||||
|
|
@ -219,6 +221,8 @@ def _parse_version_info(field_values: FieldValues) -> version.V2VersionInfo:
|
|||
bid=bid,
|
||||
tag=tag,
|
||||
pytag=pytag,
|
||||
inc0=inc0,
|
||||
inc1=inc1,
|
||||
)
|
||||
return vinfo
|
||||
|
||||
|
|
@ -567,9 +571,9 @@ def _iter_reset_field_items(
|
|||
# Any field to the left of another can reset all to the right
|
||||
has_reset = False
|
||||
for field in fields:
|
||||
zero_val = version.V2_FIELD_ZERO_VALUES.get(field)
|
||||
if has_reset and zero_val is not None:
|
||||
yield field, zero_val
|
||||
initial_val = version.V2_FIELD_INITIAL_VALUES.get(field)
|
||||
if has_reset and initial_val is not None:
|
||||
yield field, initial_val
|
||||
elif getattr(old_vinfo, field) != getattr(cur_vinfo, field):
|
||||
has_reset = True
|
||||
|
||||
|
|
@ -598,6 +602,16 @@ def _incr_numeric(
|
|||
|
||||
cur_vinfo = cur_vinfo._replace(bid=lexid.next_id(cur_vinfo.bid))
|
||||
|
||||
if 'inc0' in reset_fields:
|
||||
cur_vinfo = cur_vinfo._replace(inc0=0)
|
||||
else:
|
||||
cur_vinfo = cur_vinfo._replace(inc0=cur_vinfo.inc0 + 1)
|
||||
|
||||
if 'inc1' in reset_fields:
|
||||
cur_vinfo = cur_vinfo._replace(inc1=1)
|
||||
else:
|
||||
cur_vinfo = cur_vinfo._replace(inc1=cur_vinfo.inc1 + 1)
|
||||
|
||||
if major and 'major' not in reset_fields:
|
||||
cur_vinfo = cur_vinfo._replace(major=cur_vinfo.major + 1, minor=0, patch=0)
|
||||
if minor and 'minor' not in reset_fields:
|
||||
|
|
|
|||
|
|
@ -73,6 +73,8 @@ class V2VersionInfo(typ.NamedTuple):
|
|||
bid : str
|
||||
tag : str
|
||||
pytag : str
|
||||
inc0 : int
|
||||
inc1 : int
|
||||
|
||||
|
||||
# The test suite may replace this.
|
||||
|
|
@ -116,18 +118,19 @@ PART_ZERO_VALUES = {
|
|||
'RELEASE': "final",
|
||||
'PYTAG' : "",
|
||||
'NUM' : "0",
|
||||
'INC' : "0",
|
||||
'INC0' : "0",
|
||||
}
|
||||
|
||||
|
||||
V2_FIELD_ZERO_VALUES = {
|
||||
V2_FIELD_INITIAL_VALUES = {
|
||||
'major': "0",
|
||||
'minor': "0",
|
||||
'patch': "0",
|
||||
'tag' : "final",
|
||||
'pytag': "",
|
||||
'num' : "0",
|
||||
'inc' : "0",
|
||||
'inc0' : "0",
|
||||
'inc1' : "1",
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue