mirror of
https://github.com/TECHNOFAB11/bumpver.git
synced 2025-12-16 16:23:51 +01:00
Add temporary pinning of increments (#197)
Fixes #196 - Add temporary pinning of increments Co-authored-by: Manuel Barkhau <mbarkhau@gmail.com>
This commit is contained in:
parent
5edb0ee3f4
commit
72227d3e75
7 changed files with 93 additions and 37 deletions
|
|
@ -224,6 +224,12 @@ def version_options(function: typ.Callable) -> typ.Callable:
|
|||
default=False,
|
||||
help="Increment release tag number (rc1, rc2, rc3..).",
|
||||
),
|
||||
click.option(
|
||||
"--pin-increments",
|
||||
is_flag=True,
|
||||
default=False,
|
||||
help="Leave the auto-increments INC0 and INC1 unchanged.",
|
||||
),
|
||||
click.option(
|
||||
"--pin-date", is_flag=True, default=False, help="Leave date components unchanged."
|
||||
),
|
||||
|
|
@ -261,17 +267,18 @@ def cli(verbose: int = 0) -> None:
|
|||
@verbose_option
|
||||
@version_options
|
||||
def test(
|
||||
old_version: str,
|
||||
pattern : str,
|
||||
verbose : int = 0,
|
||||
major : bool = False,
|
||||
minor : bool = False,
|
||||
patch : bool = False,
|
||||
tag : str = None,
|
||||
tag_num : bool = False,
|
||||
pin_date : bool = False,
|
||||
date : typ.Optional[str] = None,
|
||||
set_version: typ.Optional[str] = None,
|
||||
old_version : str,
|
||||
pattern : str,
|
||||
verbose : int = 0,
|
||||
major : bool = False,
|
||||
minor : bool = False,
|
||||
patch : bool = False,
|
||||
tag : str = None,
|
||||
tag_num : bool = False,
|
||||
pin_increments: bool = False,
|
||||
pin_date : bool = False,
|
||||
date : typ.Optional[str] = None,
|
||||
set_version : typ.Optional[str] = None,
|
||||
) -> None:
|
||||
"""Increment a version number for demo purposes."""
|
||||
_configure_logging(verbose=max(_VERBOSE, verbose))
|
||||
|
|
@ -291,6 +298,7 @@ def test(
|
|||
patch=patch,
|
||||
tag=tag,
|
||||
tag_num=tag_num,
|
||||
pin_increments=pin_increments,
|
||||
pin_date=pin_date,
|
||||
maybe_date=maybe_date,
|
||||
)
|
||||
|
|
@ -521,13 +529,14 @@ def incr_dispatch(
|
|||
old_version: str,
|
||||
raw_pattern: str,
|
||||
*,
|
||||
major : bool = False,
|
||||
minor : bool = False,
|
||||
patch : bool = False,
|
||||
tag : str = None,
|
||||
tag_num : bool = False,
|
||||
pin_date : bool = False,
|
||||
maybe_date: typ.Optional[dt.date] = None,
|
||||
major : bool = False,
|
||||
minor : bool = False,
|
||||
patch : bool = False,
|
||||
tag : str = None,
|
||||
tag_num : bool = False,
|
||||
pin_increments: bool = False,
|
||||
pin_date : bool = False,
|
||||
maybe_date : typ.Optional[dt.date] = None,
|
||||
) -> typ.Optional[str]:
|
||||
v1_parts = list(v1patterns.PART_PATTERNS) + list(v1patterns.FULL_PART_FORMATS)
|
||||
has_v1_part = any("{" + part + "}" in raw_pattern for part in v1_parts)
|
||||
|
|
@ -562,6 +571,7 @@ def incr_dispatch(
|
|||
patch=patch,
|
||||
tag=tag,
|
||||
tag_num=tag_num,
|
||||
pin_increments=pin_increments,
|
||||
pin_date=pin_date,
|
||||
maybe_date=maybe_date,
|
||||
)
|
||||
|
|
@ -749,6 +759,7 @@ def update(
|
|||
patch : bool = False,
|
||||
tag : typ.Optional[str] = None,
|
||||
tag_num : bool = False,
|
||||
pin_increments: bool = False,
|
||||
pin_date : bool = False,
|
||||
date : typ.Optional[str] = None,
|
||||
set_version : typ.Optional[str] = None,
|
||||
|
|
@ -787,6 +798,7 @@ def update(
|
|||
patch=patch,
|
||||
tag=tag,
|
||||
tag_num=tag_num,
|
||||
pin_increments=pin_increments,
|
||||
pin_date=pin_date,
|
||||
maybe_date=maybe_date,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -661,14 +661,15 @@ def _reset_rollover_fields(
|
|||
|
||||
|
||||
def _incr_numeric(
|
||||
raw_pattern: str,
|
||||
old_vinfo : version.V2VersionInfo,
|
||||
cur_vinfo : version.V2VersionInfo,
|
||||
major : bool,
|
||||
minor : bool,
|
||||
patch : bool,
|
||||
tag : typ.Optional[str],
|
||||
tag_num : bool,
|
||||
raw_pattern : str,
|
||||
old_vinfo : version.V2VersionInfo,
|
||||
cur_vinfo : version.V2VersionInfo,
|
||||
major : bool,
|
||||
minor : bool,
|
||||
patch : bool,
|
||||
tag : typ.Optional[str],
|
||||
tag_num : bool,
|
||||
pin_increments: bool,
|
||||
) -> version.V2VersionInfo:
|
||||
"""Increment (and reset to zero) non CalVer parts.
|
||||
|
||||
|
|
@ -685,6 +686,7 @@ def _incr_numeric(
|
|||
... patch=True,
|
||||
... tag='beta',
|
||||
... tag_num=False,
|
||||
... pin_increments=False,
|
||||
... )
|
||||
>>> (new_vinfo.major, new_vinfo.minor, new_vinfo.patch, new_vinfo.tag, new_vinfo.pytag, new_vinfo.num)
|
||||
(1, 2, 4, 'beta', 'b', 0)
|
||||
|
|
@ -704,8 +706,9 @@ def _incr_numeric(
|
|||
pytag = version.PEP440_TAG_BY_TAG[tag]
|
||||
cur_vinfo = cur_vinfo._replace(pytag=pytag)
|
||||
|
||||
cur_vinfo = cur_vinfo._replace(inc0=cur_vinfo.inc0 + 1)
|
||||
cur_vinfo = cur_vinfo._replace(inc1=cur_vinfo.inc1 + 1)
|
||||
if not pin_increments:
|
||||
cur_vinfo = cur_vinfo._replace(inc0=cur_vinfo.inc0 + 1)
|
||||
cur_vinfo = cur_vinfo._replace(inc1=cur_vinfo.inc1 + 1)
|
||||
|
||||
# prevent truncation of leading zeros
|
||||
if int(cur_vinfo.bid) < 1000:
|
||||
|
|
@ -738,13 +741,14 @@ def incr(
|
|||
old_version: str,
|
||||
raw_pattern: str = "vYYYY0M.BUILD[-TAG]",
|
||||
*,
|
||||
major : bool = False,
|
||||
minor : bool = False,
|
||||
patch : bool = False,
|
||||
tag : typ.Optional[str] = None,
|
||||
tag_num : bool = False,
|
||||
pin_date : bool = False,
|
||||
maybe_date: typ.Optional[dt.date] = None,
|
||||
major : bool = False,
|
||||
minor : bool = False,
|
||||
patch : bool = False,
|
||||
tag : typ.Optional[str] = None,
|
||||
tag_num : bool = False,
|
||||
pin_increments: bool = False,
|
||||
pin_date : bool = False,
|
||||
maybe_date : typ.Optional[dt.date] = None,
|
||||
) -> typ.Optional[str]:
|
||||
"""Increment version string.
|
||||
|
||||
|
|
@ -784,6 +788,7 @@ def incr(
|
|||
patch=patch,
|
||||
tag=tag,
|
||||
tag_num=tag_num,
|
||||
pin_increments=pin_increments,
|
||||
)
|
||||
|
||||
new_version = format_version(cur_vinfo, raw_pattern)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue