mirror of
https://github.com/TECHNOFAB11/bumpver.git
synced 2025-12-12 14:30:09 +01:00
add --pin-date flag
This commit is contained in:
parent
033a324488
commit
f6f3a2fd00
4 changed files with 36 additions and 14 deletions
|
|
@ -88,6 +88,9 @@ def cli(verbose: int = 0) -> None:
|
||||||
@click.option("--major", is_flag=True, default=False, help="Increment major component.")
|
@click.option("--major", is_flag=True, default=False, help="Increment major component.")
|
||||||
@click.option("--minor", is_flag=True, default=False, help="Increment minor component.")
|
@click.option("--minor", is_flag=True, default=False, help="Increment minor component.")
|
||||||
@click.option("--patch", is_flag=True, default=False, help="Increment patch component.")
|
@click.option("--patch", is_flag=True, default=False, help="Increment patch component.")
|
||||||
|
@click.option(
|
||||||
|
"-p", "--pin-date", is_flag=True, default=False, help="Leave date components unchanged."
|
||||||
|
)
|
||||||
def test(
|
def test(
|
||||||
old_version: str,
|
old_version: str,
|
||||||
pattern : str = "{pycalver}",
|
pattern : str = "{pycalver}",
|
||||||
|
|
@ -96,6 +99,7 @@ def test(
|
||||||
major : bool = False,
|
major : bool = False,
|
||||||
minor : bool = False,
|
minor : bool = False,
|
||||||
patch : bool = False,
|
patch : bool = False,
|
||||||
|
pin_date : bool = False,
|
||||||
) -> 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))
|
||||||
|
|
@ -110,6 +114,7 @@ def test(
|
||||||
major=major,
|
major=major,
|
||||||
minor=minor,
|
minor=minor,
|
||||||
patch=patch,
|
patch=patch,
|
||||||
|
pin_date=pin_date,
|
||||||
)
|
)
|
||||||
if new_version is None:
|
if new_version is None:
|
||||||
logger.error(f"Invalid version '{old_version}' and/or pattern '{pattern}'.")
|
logger.error(f"Invalid version '{old_version}' and/or pattern '{pattern}'.")
|
||||||
|
|
@ -175,10 +180,11 @@ def _incr(
|
||||||
old_version: str,
|
old_version: str,
|
||||||
pattern : str = "{pycalver}",
|
pattern : str = "{pycalver}",
|
||||||
*,
|
*,
|
||||||
release: str = None,
|
release : str = None,
|
||||||
major : bool = False,
|
major : bool = False,
|
||||||
minor : bool = False,
|
minor : bool = False,
|
||||||
patch : bool = False,
|
patch : bool = False,
|
||||||
|
pin_date: bool = False,
|
||||||
) -> typ.Optional[str]:
|
) -> typ.Optional[str]:
|
||||||
is_v1_pattern = "{" in pattern
|
is_v1_pattern = "{" in pattern
|
||||||
if is_v1_pattern:
|
if is_v1_pattern:
|
||||||
|
|
@ -189,6 +195,7 @@ def _incr(
|
||||||
major=major,
|
major=major,
|
||||||
minor=minor,
|
minor=minor,
|
||||||
patch=patch,
|
patch=patch,
|
||||||
|
pin_date=pin_date,
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
return v2version.incr(
|
return v2version.incr(
|
||||||
|
|
@ -198,6 +205,7 @@ def _incr(
|
||||||
major=major,
|
major=major,
|
||||||
minor=minor,
|
minor=minor,
|
||||||
patch=patch,
|
patch=patch,
|
||||||
|
pin_date=pin_date,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -325,6 +333,9 @@ def _update_cfg_from_vcs(cfg: config.Config, fetch: bool) -> config.Config:
|
||||||
@click.option("--major", is_flag=True, default=False, help="Increment major component.")
|
@click.option("--major", is_flag=True, default=False, help="Increment major component.")
|
||||||
@click.option("--minor", is_flag=True, default=False, help="Increment minor component.")
|
@click.option("--minor", is_flag=True, default=False, help="Increment minor component.")
|
||||||
@click.option("--patch", is_flag=True, default=False, help="Increment patch component.")
|
@click.option("--patch", is_flag=True, default=False, help="Increment patch component.")
|
||||||
|
@click.option(
|
||||||
|
"-p", "--pin-date", is_flag=True, default=False, help="Leave date components unchanged."
|
||||||
|
)
|
||||||
def bump(
|
def bump(
|
||||||
release : typ.Optional[str] = None,
|
release : typ.Optional[str] = None,
|
||||||
verbose : int = 0,
|
verbose : int = 0,
|
||||||
|
|
@ -334,6 +345,7 @@ def bump(
|
||||||
major : bool = False,
|
major : bool = False,
|
||||||
minor : bool = False,
|
minor : bool = False,
|
||||||
patch : bool = False,
|
patch : bool = False,
|
||||||
|
pin_date : bool = False,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Increment the current version string and update project files."""
|
"""Increment the current version string and update project files."""
|
||||||
verbose = max(_VERBOSE, verbose)
|
verbose = max(_VERBOSE, verbose)
|
||||||
|
|
@ -359,6 +371,7 @@ def bump(
|
||||||
major=major,
|
major=major,
|
||||||
minor=minor,
|
minor=minor,
|
||||||
patch=patch,
|
patch=patch,
|
||||||
|
pin_date=pin_date,
|
||||||
)
|
)
|
||||||
|
|
||||||
if new_version is None:
|
if new_version is None:
|
||||||
|
|
|
||||||
|
|
@ -434,10 +434,11 @@ def incr(
|
||||||
old_version: str,
|
old_version: str,
|
||||||
pattern : str = "{pycalver}",
|
pattern : str = "{pycalver}",
|
||||||
*,
|
*,
|
||||||
release: str = None,
|
release : str = None,
|
||||||
major : bool = False,
|
major : bool = False,
|
||||||
minor : bool = False,
|
minor : bool = False,
|
||||||
patch : bool = False,
|
patch : bool = False,
|
||||||
|
pin_date: bool = False,
|
||||||
) -> typ.Optional[str]:
|
) -> typ.Optional[str]:
|
||||||
"""Increment version string.
|
"""Increment version string.
|
||||||
|
|
||||||
|
|
@ -451,7 +452,7 @@ def incr(
|
||||||
|
|
||||||
cur_vinfo = old_vinfo
|
cur_vinfo = old_vinfo
|
||||||
|
|
||||||
cur_cal_nfo = cal_info()
|
cur_cal_nfo = _ver_to_cal_info(old_vinfo) if pin_date else cal_info()
|
||||||
|
|
||||||
old_date = (old_vinfo.year or 0 , old_vinfo.month or 0 , old_vinfo.dom or 0)
|
old_date = (old_vinfo.year or 0 , old_vinfo.month or 0 , old_vinfo.dom or 0)
|
||||||
cur_date = (cur_cal_nfo.year or 0, cur_cal_nfo.month or 0, cur_cal_nfo.dom or 0)
|
cur_date = (cur_cal_nfo.year or 0, cur_cal_nfo.month or 0, cur_cal_nfo.dom or 0)
|
||||||
|
|
|
||||||
|
|
@ -586,10 +586,11 @@ def incr(
|
||||||
old_version: str,
|
old_version: str,
|
||||||
pattern : str = "vYYYY0M.BUILD[-TAG]",
|
pattern : str = "vYYYY0M.BUILD[-TAG]",
|
||||||
*,
|
*,
|
||||||
release: str = None,
|
release : str = None,
|
||||||
major : bool = False,
|
major : bool = False,
|
||||||
minor : bool = False,
|
minor : bool = False,
|
||||||
patch : bool = False,
|
patch : bool = False,
|
||||||
|
pin_date: bool = False,
|
||||||
) -> typ.Optional[str]:
|
) -> typ.Optional[str]:
|
||||||
"""Increment version string.
|
"""Increment version string.
|
||||||
|
|
||||||
|
|
@ -603,7 +604,7 @@ def incr(
|
||||||
|
|
||||||
cur_vinfo = old_vinfo
|
cur_vinfo = old_vinfo
|
||||||
|
|
||||||
cur_cal_nfo = cal_info()
|
cur_cal_nfo = _ver_to_cal_info(old_vinfo) if pin_date else cal_info()
|
||||||
|
|
||||||
old_date = (old_vinfo.year_y or 0 , old_vinfo.month or 0 , old_vinfo.dom or 0)
|
old_date = (old_vinfo.year_y or 0 , old_vinfo.month or 0 , old_vinfo.dom or 0)
|
||||||
cur_date = (cur_cal_nfo.year_y or 0, cur_cal_nfo.month or 0, cur_cal_nfo.dom or 0)
|
cur_date = (cur_cal_nfo.year_y or 0, cur_cal_nfo.month or 0, cur_cal_nfo.dom or 0)
|
||||||
|
|
|
||||||
|
|
@ -102,6 +102,13 @@ def test_incr_default(runner):
|
||||||
assert f"Version: {new_version}\n" in result.output
|
assert f"Version: {new_version}\n" in result.output
|
||||||
|
|
||||||
|
|
||||||
|
def test_incr_pin_date(runner):
|
||||||
|
old_version = "v201701.0999-alpha"
|
||||||
|
result = runner.invoke(cli, ['test', "-vv", "--pin-date", old_version])
|
||||||
|
assert result.exit_code == 0
|
||||||
|
assert "Version: v201701.11000-alpha\n" in result.output
|
||||||
|
|
||||||
|
|
||||||
def test_incr_semver(runner):
|
def test_incr_semver(runner):
|
||||||
semver_pattern = "{MAJOR}.{MINOR}.{PATCH}"
|
semver_pattern = "{MAJOR}.{MINOR}.{PATCH}"
|
||||||
old_version = "0.1.0"
|
old_version = "0.1.0"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue