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
|
# 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
|
## BumpVer 2022.1119
|
||||||
|
|
||||||
- Fix [#190][gh_i190]: Allow multiple patterns on the same line
|
- 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.
|
--date <ISODATE> Set explicit date in format YYYY-0M-0D (e.g.
|
||||||
2021-05-13).
|
2021-05-13).
|
||||||
--pin-date Leave date components unchanged.
|
--pin-date Leave date components unchanged.
|
||||||
|
--pin-increments Leave the auto-increments INC0 and INC1
|
||||||
--tag-num Increment release tag number (rc1, rc2,
|
--tag-num Increment release tag number (rc1, rc2,
|
||||||
rc3..).
|
rc3..).
|
||||||
-t, --tag <NAME> Override release tag of current_version. Valid
|
-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
|
# https://github.com/pytest-dev/pytest-html/blob/master/CHANGES.rst
|
||||||
# pytest-html 2.0+ doesn't support python2.7
|
# pytest-html 2.0+ doesn't support python2.7
|
||||||
pytest-html<2.0
|
pytest-html<2.0
|
||||||
|
py
|
||||||
|
|
||||||
readme_renderer[md]
|
readme_renderer[md]
|
||||||
twine
|
twine
|
||||||
|
|
|
||||||
|
|
@ -131,10 +131,10 @@ jobs = 4
|
||||||
output-format = colorized
|
output-format = colorized
|
||||||
|
|
||||||
# Maximum number of locals for function / method body
|
# Maximum number of locals for function / method body
|
||||||
max-locals = 16
|
max-locals = 17
|
||||||
|
|
||||||
# Maximum number of arguments for function / method
|
# Maximum number of arguments for function / method
|
||||||
max-args = 8
|
max-args = 9
|
||||||
|
|
||||||
# Maximum number of branch for function / method body
|
# Maximum number of branch for function / method body
|
||||||
max-branches = 14
|
max-branches = 14
|
||||||
|
|
|
||||||
|
|
@ -224,6 +224,12 @@ def version_options(function: typ.Callable) -> typ.Callable:
|
||||||
default=False,
|
default=False,
|
||||||
help="Increment release tag number (rc1, rc2, rc3..).",
|
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(
|
click.option(
|
||||||
"--pin-date", is_flag=True, default=False, help="Leave date components unchanged."
|
"--pin-date", is_flag=True, default=False, help="Leave date components unchanged."
|
||||||
),
|
),
|
||||||
|
|
@ -261,7 +267,7 @@ def cli(verbose: int = 0) -> None:
|
||||||
@verbose_option
|
@verbose_option
|
||||||
@version_options
|
@version_options
|
||||||
def test(
|
def test(
|
||||||
old_version: str,
|
old_version : str,
|
||||||
pattern : str,
|
pattern : str,
|
||||||
verbose : int = 0,
|
verbose : int = 0,
|
||||||
major : bool = False,
|
major : bool = False,
|
||||||
|
|
@ -269,9 +275,10 @@ def test(
|
||||||
patch : bool = False,
|
patch : bool = False,
|
||||||
tag : str = None,
|
tag : str = None,
|
||||||
tag_num : bool = False,
|
tag_num : bool = False,
|
||||||
|
pin_increments: bool = False,
|
||||||
pin_date : bool = False,
|
pin_date : bool = False,
|
||||||
date : typ.Optional[str] = None,
|
date : typ.Optional[str] = None,
|
||||||
set_version: typ.Optional[str] = None,
|
set_version : typ.Optional[str] = None,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Increment a version number for demo purposes."""
|
"""Increment a version number for demo purposes."""
|
||||||
_configure_logging(verbose=max(_VERBOSE, verbose))
|
_configure_logging(verbose=max(_VERBOSE, verbose))
|
||||||
|
|
@ -291,6 +298,7 @@ def test(
|
||||||
patch=patch,
|
patch=patch,
|
||||||
tag=tag,
|
tag=tag,
|
||||||
tag_num=tag_num,
|
tag_num=tag_num,
|
||||||
|
pin_increments=pin_increments,
|
||||||
pin_date=pin_date,
|
pin_date=pin_date,
|
||||||
maybe_date=maybe_date,
|
maybe_date=maybe_date,
|
||||||
)
|
)
|
||||||
|
|
@ -526,8 +534,9 @@ def incr_dispatch(
|
||||||
patch : bool = False,
|
patch : bool = False,
|
||||||
tag : str = None,
|
tag : str = None,
|
||||||
tag_num : bool = False,
|
tag_num : bool = False,
|
||||||
|
pin_increments: bool = False,
|
||||||
pin_date : bool = False,
|
pin_date : bool = False,
|
||||||
maybe_date: typ.Optional[dt.date] = None,
|
maybe_date : typ.Optional[dt.date] = None,
|
||||||
) -> typ.Optional[str]:
|
) -> typ.Optional[str]:
|
||||||
v1_parts = list(v1patterns.PART_PATTERNS) + list(v1patterns.FULL_PART_FORMATS)
|
v1_parts = list(v1patterns.PART_PATTERNS) + list(v1patterns.FULL_PART_FORMATS)
|
||||||
has_v1_part = any("{" + part + "}" in raw_pattern for part in v1_parts)
|
has_v1_part = any("{" + part + "}" in raw_pattern for part in v1_parts)
|
||||||
|
|
@ -562,6 +571,7 @@ def incr_dispatch(
|
||||||
patch=patch,
|
patch=patch,
|
||||||
tag=tag,
|
tag=tag,
|
||||||
tag_num=tag_num,
|
tag_num=tag_num,
|
||||||
|
pin_increments=pin_increments,
|
||||||
pin_date=pin_date,
|
pin_date=pin_date,
|
||||||
maybe_date=maybe_date,
|
maybe_date=maybe_date,
|
||||||
)
|
)
|
||||||
|
|
@ -749,6 +759,7 @@ def update(
|
||||||
patch : bool = False,
|
patch : bool = False,
|
||||||
tag : typ.Optional[str] = None,
|
tag : typ.Optional[str] = None,
|
||||||
tag_num : bool = False,
|
tag_num : bool = False,
|
||||||
|
pin_increments: bool = False,
|
||||||
pin_date : bool = False,
|
pin_date : bool = False,
|
||||||
date : typ.Optional[str] = None,
|
date : typ.Optional[str] = None,
|
||||||
set_version : typ.Optional[str] = None,
|
set_version : typ.Optional[str] = None,
|
||||||
|
|
@ -787,6 +798,7 @@ def update(
|
||||||
patch=patch,
|
patch=patch,
|
||||||
tag=tag,
|
tag=tag,
|
||||||
tag_num=tag_num,
|
tag_num=tag_num,
|
||||||
|
pin_increments=pin_increments,
|
||||||
pin_date=pin_date,
|
pin_date=pin_date,
|
||||||
maybe_date=maybe_date,
|
maybe_date=maybe_date,
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -661,7 +661,7 @@ def _reset_rollover_fields(
|
||||||
|
|
||||||
|
|
||||||
def _incr_numeric(
|
def _incr_numeric(
|
||||||
raw_pattern: str,
|
raw_pattern : str,
|
||||||
old_vinfo : version.V2VersionInfo,
|
old_vinfo : version.V2VersionInfo,
|
||||||
cur_vinfo : version.V2VersionInfo,
|
cur_vinfo : version.V2VersionInfo,
|
||||||
major : bool,
|
major : bool,
|
||||||
|
|
@ -669,6 +669,7 @@ def _incr_numeric(
|
||||||
patch : bool,
|
patch : bool,
|
||||||
tag : typ.Optional[str],
|
tag : typ.Optional[str],
|
||||||
tag_num : bool,
|
tag_num : bool,
|
||||||
|
pin_increments: bool,
|
||||||
) -> version.V2VersionInfo:
|
) -> version.V2VersionInfo:
|
||||||
"""Increment (and reset to zero) non CalVer parts.
|
"""Increment (and reset to zero) non CalVer parts.
|
||||||
|
|
||||||
|
|
@ -685,6 +686,7 @@ def _incr_numeric(
|
||||||
... patch=True,
|
... patch=True,
|
||||||
... tag='beta',
|
... tag='beta',
|
||||||
... tag_num=False,
|
... tag_num=False,
|
||||||
|
... pin_increments=False,
|
||||||
... )
|
... )
|
||||||
>>> (new_vinfo.major, new_vinfo.minor, new_vinfo.patch, new_vinfo.tag, new_vinfo.pytag, new_vinfo.num)
|
>>> (new_vinfo.major, new_vinfo.minor, new_vinfo.patch, new_vinfo.tag, new_vinfo.pytag, new_vinfo.num)
|
||||||
(1, 2, 4, 'beta', 'b', 0)
|
(1, 2, 4, 'beta', 'b', 0)
|
||||||
|
|
@ -704,6 +706,7 @@ def _incr_numeric(
|
||||||
pytag = version.PEP440_TAG_BY_TAG[tag]
|
pytag = version.PEP440_TAG_BY_TAG[tag]
|
||||||
cur_vinfo = cur_vinfo._replace(pytag=pytag)
|
cur_vinfo = cur_vinfo._replace(pytag=pytag)
|
||||||
|
|
||||||
|
if not pin_increments:
|
||||||
cur_vinfo = cur_vinfo._replace(inc0=cur_vinfo.inc0 + 1)
|
cur_vinfo = cur_vinfo._replace(inc0=cur_vinfo.inc0 + 1)
|
||||||
cur_vinfo = cur_vinfo._replace(inc1=cur_vinfo.inc1 + 1)
|
cur_vinfo = cur_vinfo._replace(inc1=cur_vinfo.inc1 + 1)
|
||||||
|
|
||||||
|
|
@ -743,8 +746,9 @@ def incr(
|
||||||
patch : bool = False,
|
patch : bool = False,
|
||||||
tag : typ.Optional[str] = None,
|
tag : typ.Optional[str] = None,
|
||||||
tag_num : bool = False,
|
tag_num : bool = False,
|
||||||
|
pin_increments: bool = False,
|
||||||
pin_date : bool = False,
|
pin_date : bool = False,
|
||||||
maybe_date: typ.Optional[dt.date] = None,
|
maybe_date : typ.Optional[dt.date] = None,
|
||||||
) -> typ.Optional[str]:
|
) -> typ.Optional[str]:
|
||||||
"""Increment version string.
|
"""Increment version string.
|
||||||
|
|
||||||
|
|
@ -784,6 +788,7 @@ def incr(
|
||||||
patch=patch,
|
patch=patch,
|
||||||
tag=tag,
|
tag=tag,
|
||||||
tag_num=tag_num,
|
tag_num=tag_num,
|
||||||
|
pin_increments=pin_increments,
|
||||||
)
|
)
|
||||||
|
|
||||||
new_version = format_version(cur_vinfo, raw_pattern)
|
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
|
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):
|
def test_incr_semver(runner):
|
||||||
semver_patterns = [
|
semver_patterns = [
|
||||||
"{semver}",
|
"{semver}",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue