mirror of
https://github.com/TECHNOFAB11/bumpver.git
synced 2025-12-12 06:20:08 +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
10
CHANGELOG.md
10
CHANGELOG.md
|
|
@ -1,5 +1,15 @@
|
|||
# Changelog for https://github.com/mbarkhau/bumpver
|
||||
|
||||
## BumpVer 2022.1120
|
||||
|
||||
- Fix [#196][gh_i196]: Add `--pin-increments`.
|
||||
|
||||
[gh_i196]: https://github.com/mbarkhau/bumpver/issues/196
|
||||
|
||||
Thank you [Markus Holtermann](https://github.com/MarkusH) for
|
||||
this contribution.
|
||||
|
||||
|
||||
## BumpVer 2022.1119
|
||||
|
||||
- Fix [#190][gh_i190]: Allow multiple patterns on the same line
|
||||
|
|
|
|||
|
|
@ -605,6 +605,7 @@ Options:
|
|||
--date <ISODATE> Set explicit date in format YYYY-0M-0D (e.g.
|
||||
2021-05-13).
|
||||
--pin-date Leave date components unchanged.
|
||||
--pin-increments Leave the auto-increments INC0 and INC1
|
||||
--tag-num Increment release tag number (rc1, rc2,
|
||||
rc3..).
|
||||
-t, --tag <NAME> Override release tag of current_version. Valid
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ pytest-cov
|
|||
# https://github.com/pytest-dev/pytest-html/blob/master/CHANGES.rst
|
||||
# pytest-html 2.0+ doesn't support python2.7
|
||||
pytest-html<2.0
|
||||
py
|
||||
|
||||
readme_renderer[md]
|
||||
twine
|
||||
|
|
|
|||
|
|
@ -131,10 +131,10 @@ jobs = 4
|
|||
output-format = colorized
|
||||
|
||||
# Maximum number of locals for function / method body
|
||||
max-locals = 16
|
||||
max-locals = 17
|
||||
|
||||
# Maximum number of arguments for function / method
|
||||
max-args = 8
|
||||
max-args = 9
|
||||
|
||||
# Maximum number of branch for function / method body
|
||||
max-branches = 14
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -156,6 +156,33 @@ def test_incr_pin_date(runner):
|
|||
assert "Version: v2017.22000-alpha\n" in result.output
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"version_pattern, old_version, new_version",
|
||||
[
|
||||
("vYYYY.INC0[-PATCH]", "v2017.0", "v2017.0-1"),
|
||||
("vYYYY.INC0[-PATCH]", "v2017.0-1", "v2017.0-2"),
|
||||
("vYYYY.INC1[-PATCH]", "v2017.1", "v2017.1-1"),
|
||||
("vYYYY.INC1[-PATCH]", "v2017.1-1", "v2017.1-2"),
|
||||
],
|
||||
)
|
||||
def test_incr_pin_increments(runner, version_pattern, old_version, new_version):
|
||||
result = runner.invoke(
|
||||
cli.cli,
|
||||
[
|
||||
'test',
|
||||
"-vv",
|
||||
"--pin-increments",
|
||||
"--patch",
|
||||
"--date",
|
||||
"2017-12-01",
|
||||
old_version,
|
||||
version_pattern,
|
||||
],
|
||||
)
|
||||
assert result.exit_code == 0
|
||||
assert f"Version: {new_version}\n" in result.output
|
||||
|
||||
|
||||
def test_incr_semver(runner):
|
||||
semver_patterns = [
|
||||
"{semver}",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue