Merge branch 'github/master' into HEAD

This commit is contained in:
Manuel Barkhau 2021-01-17 21:52:35 +00:00
commit d0bde26173
29 changed files with 152 additions and 79 deletions

3
.gitignore vendored
View file

@ -217,3 +217,6 @@ fabric.properties
# Android studio 3.1+ serialized cache file # Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser .idea/caches/build_file_checksums.ser
# Visual Studio Code
.vscode

View file

@ -1,5 +1,15 @@
# Changelog for https://github.com/mbarkhau/pycalver # Changelog for https://github.com/mbarkhau/pycalver
## BumpVer 2021.1109
- Add `-e/--env` option to support shell script automation.
- Fix [github#151][github_i151]: invalid increment of `TAGNUM` when `TAG=final` is set.
[github_i151]: https://gitlab.com/mbarkhau/pycalver/-/issues/15
Thank you to Dave Wapstra @dwapstra for your contributions.
## BumpVer 2020.1108 ## BumpVer 2020.1108
- Don't match empty patterns (possibly causing a whole file to be rewritten if braces `[]` are not escaped). - Don't match empty patterns (possibly causing a whole file to be rewritten if braces `[]` are not escaped).

View file

@ -1,4 +1,4 @@
MIT License Copyright (c) 2018-2020 Manuel Barkhau (mbarkhau@gmail.com) MIT License Copyright (c) 2018-2021 Manuel Barkhau (mbarkhau@gmail.com)
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal

View file

@ -22,7 +22,7 @@ Project/Repo:
[![MIT License][img_license]][url_license] [![MIT License][img_license]][url_license]
[![Supported Python Versions][img_pyversions]][url_pyversions] [![Supported Python Versions][img_pyversions]][url_pyversions]
[![CalVer 2020.1108][img_version]][url_version] [![CalVer 2021.1109][img_version]][url_version]
[![PyPI Releases][img_pypi]][url_pypi] [![PyPI Releases][img_pypi]][url_pypi]
[![PyPI Downloads][img_downloads]][url_downloads] [![PyPI Downloads][img_downloads]][url_downloads]
@ -56,7 +56,7 @@ Code Quality/CI:
[img_downloads]: https://pepy.tech/badge/bumpver/month [img_downloads]: https://pepy.tech/badge/bumpver/month
[url_downloads]: https://pepy.tech/project/bumpver [url_downloads]: https://pepy.tech/project/bumpver
[img_version]: https://img.shields.io/static/v1.svg?label=CalVer&message=2020.1108&color=blue [img_version]: https://img.shields.io/static/v1.svg?label=CalVer&message=2021.1109&color=blue
[url_version]: https://pypi.org/project/bumpver/ [url_version]: https://pypi.org/project/bumpver/
[img_pypi]: https://img.shields.io/badge/PyPI-wheels-green.svg [img_pypi]: https://img.shields.io/badge/PyPI-wheels-green.svg
@ -538,7 +538,7 @@ ERROR - No patterns matched for file 'src/mymodule/utils.py'
$ bumpver --help $ bumpver --help
Usage: bumpver [OPTIONS] COMMAND [ARGS]... Usage: bumpver [OPTIONS] COMMAND [ARGS]...
Automatically update CalVer version strings in plaintext files. Automatically update version strings in plaintext files.
Options: Options:
--version Show the version and exit. --version Show the version and exit.
@ -591,6 +591,21 @@ Options:
<!-- END bumpver update --help --> <!-- END bumpver update --help -->
To help with shell script automation, you can use `bumpver show --env`.
```shell
$ bumpver show -n --env
YEAR_Y=2020
YEAR_G=
...
TAG=final
...
$ eval $(bumpver show -n --env)
$ echo $TAG
final
```
### Part Overview ### Part Overview
@ -749,7 +764,7 @@ The create an initial configuration for project with `bumpver init`.
$ pip install bumpver $ pip install bumpver
... ...
Installing collected packages: click toml lexid bumpver Installing collected packages: click toml lexid bumpver
Successfully installed bumpver-2020.1108 Successfully installed bumpver-2021.1109
$ cd myproject $ cd myproject
~/myproject/ ~/myproject/

View file

@ -13,7 +13,7 @@ PACKAGE_NAME="bumpver"
GIT_REPO_NAMESPACE="mbarkhau" GIT_REPO_NAMESPACE="mbarkhau"
GIT_REPO_DOMAIN="github.com" GIT_REPO_DOMAIN="github.com"
PACKAGE_VERSION="2020.1108" PACKAGE_VERSION="2021.1109"
DEFAULT_PYTHON_VERSION="python=3.8" DEFAULT_PYTHON_VERSION="python=3.8"
SUPPORTED_PYTHON_VERSIONS="python=2.7 python=3.6 pypy2.7 pypy3.5 python=3.8" SUPPORTED_PYTHON_VERSIONS="python=2.7 python=3.6 pypy2.7 pypy3.5 python=3.8"

View file

@ -1,9 +1,9 @@
Individual files contain the following tag instead of the full license text. Individual files contain the following tag instead of the full license text.
This file is part of the pycalver project This file is part of the bumpver project
https://github.com/mbarkhau/pycalver https://github.com/mbarkhau/bumpver
Copyright (c) 2018-2020 Manuel Barkhau (mbarkhau@gmail.com) - MIT License Copyright (c) 2018-2021 Manuel Barkhau (mbarkhau@gmail.com) - MIT License
SPDX-License-Identifier: MIT SPDX-License-Identifier: MIT
This enables machine processing of license information based on the SPDX This enables machine processing of license information based on the SPDX

View file

@ -89,7 +89,7 @@ addopts = --doctest-modules
[bumpver] [bumpver]
current_version = "2020.1108" current_version = "2021.1109"
version_pattern = "YYYY.BUILD[-TAG]" version_pattern = "YYYY.BUILD[-TAG]"
commit_message = "bump {old_version} -> {new_version}" commit_message = "bump {old_version} -> {new_version}"
commit = True commit = True

View file

@ -1,5 +1,5 @@
# This file is part of the pycalver project # This file is part of the bumpver project
# https://github.com/mbarkhau/pycalver # https://github.com/mbarkhau/bumpver
# #
# Copyright (c) 2018-2020 Manuel Barkhau (mbarkhau@gmail.com) - MIT License # Copyright (c) 2018-2020 Manuel Barkhau (mbarkhau@gmail.com) - MIT License
# SPDX-License-Identifier: MIT # SPDX-License-Identifier: MIT
@ -63,7 +63,7 @@ setuptools.setup(
author="Manuel Barkhau", author="Manuel Barkhau",
author_email="mbarkhau@gmail.com", author_email="mbarkhau@gmail.com",
url="https://github.com/mbarkhau/bumpver", url="https://github.com/mbarkhau/bumpver",
version="2020.1108", version="2021.1109",
keywords="version bumpver calver semver versioning bumpversion pep440", keywords="version bumpver calver semver versioning bumpversion pep440",
description="Bump version numbers in project files.", description="Bump version numbers in project files.",
long_description=long_description, long_description=long_description,

View file

@ -1,8 +1,8 @@
# This file is part of the pycalver project # This file is part of the bumpver project
# https://github.com/mbarkhau/pycalver # https://github.com/mbarkhau/bumpver
# #
# Copyright (c) 2018-2020 Manuel Barkhau (mbarkhau@gmail.com) - MIT License # Copyright (c) 2018-2021 Manuel Barkhau (mbarkhau@gmail.com) - MIT License
# SPDX-License-Identifier: MIT # SPDX-License-Identifier: MIT
"""BumpVer: A CLI program for versioning.""" """BumpVer: A CLI program for versioning."""
__version__ = "2020.1108" __version__ = "2021.1109"

View file

@ -1,8 +1,8 @@
#!/usr/bin/env python #!/usr/bin/env python
# This file is part of the pycalver project # This file is part of the bumpver project
# https://github.com/mbarkhau/pycalver # https://github.com/mbarkhau/bumpver
# #
# Copyright (c) 2018-2020 Manuel Barkhau (mbarkhau@gmail.com) - MIT License # Copyright (c) 2018-2021 Manuel Barkhau (mbarkhau@gmail.com) - MIT License
# SPDX-License-Identifier: MIT # SPDX-License-Identifier: MIT
""" """
__main__ module for BumpVer. __main__ module for BumpVer.

View file

@ -1,8 +1,8 @@
#!/usr/bin/env python #!/usr/bin/env python
# This file is part of the pycalver project # This file is part of the bumpver project
# https://github.com/mbarkhau/pycalver # https://github.com/mbarkhau/bumpver
# #
# Copyright (c) 2018-2020 Manuel Barkhau (mbarkhau@gmail.com) - MIT License # Copyright (c) 2018-2021 Manuel Barkhau (mbarkhau@gmail.com) - MIT License
# SPDX-License-Identifier: MIT # SPDX-License-Identifier: MIT
"""cli module for BumpVer.""" """cli module for BumpVer."""
import io import io
@ -189,6 +189,15 @@ fetch_option = click.option(
) )
env_option = click.option(
"-e",
"--env",
is_flag=True,
default=False,
help="Print version state for use with shell scripts: eval $(bumpver show --env)",
)
def version_options(function: typ.Callable) -> typ.Callable: def version_options(function: typ.Callable) -> typ.Callable:
decorators = [ decorators = [
click.option("--major", is_flag=True, default=False, help="Increment major component."), click.option("--major", is_flag=True, default=False, help="Increment major component."),
@ -237,7 +246,7 @@ def version_options(function: typ.Callable) -> typ.Callable:
@click.group() @click.group()
@click.version_option(version="2020.1108") @click.version_option(version="2021.1109")
@click.help_option() @click.help_option()
@verbose_option @verbose_option
def cli(verbose: int = 0) -> None: def cli(verbose: int = 0) -> None:
@ -413,7 +422,8 @@ def grep(
@cli.command() @cli.command()
@verbose_option @verbose_option
@fetch_option @fetch_option
def show(verbose: int = 0, fetch: bool = True) -> None: @env_option
def show(verbose: int = 0, fetch: bool = True, env: bool = False) -> None:
"""Show current version of your project.""" """Show current version of your project."""
_configure_logging(verbose=max(_VERBOSE, verbose)) _configure_logging(verbose=max(_VERBOSE, verbose))
@ -424,8 +434,15 @@ def show(verbose: int = 0, fetch: bool = True) -> None:
sys.exit(1) sys.exit(1)
cfg = _update_cfg_from_vcs(cfg, fetch) cfg = _update_cfg_from_vcs(cfg, fetch)
click.echo(f"Current Version: {cfg.current_version}") if env:
click.echo(f"PEP440 : {cfg.pep440_version}") version_info = v2version.parse_version_info(cfg.current_version, cfg.version_pattern)
for key, val in version_info._asdict().items():
click.echo(f"{key.upper()}={val if val else ''}")
click.echo(f"CURRENT_VERSION={cfg.current_version}")
click.echo(f"PEP440_VERSION={cfg.pep440_version}")
else:
click.echo(f"Current Version: {cfg.current_version}")
click.echo(f"PEP440 : {cfg.pep440_version}")
def _colored_diff_lines(diff: str) -> typ.Iterable[str]: def _colored_diff_lines(diff: str) -> typ.Iterable[str]:

View file

@ -1,7 +1,7 @@
# This file is part of the pycalver project # This file is part of the bumpver project
# https://gitlab.com/mbarkhau/pycalver # https://gitlab.com/mbarkhau/bumpver
# #
# Copyright (c) 2018-2020 Manuel Barkhau (mbarkhau@gmail.com) - MIT License # Copyright (c) 2018-2021 Manuel Barkhau (mbarkhau@gmail.com) - MIT License
# SPDX-License-Identifier: MIT # SPDX-License-Identifier: MIT
"""Parse bumpver.toml, setup.cfg or pyproject.toml files.""" """Parse bumpver.toml, setup.cfg or pyproject.toml files."""

View file

@ -1,7 +1,7 @@
# This file is part of the pycalver project # This file is part of the bumpver project
# https://github.com/mbarkhau/pycalver # https://github.com/mbarkhau/bumpver
# #
# Copyright (c) 2018-2020 Manuel Barkhau (mbarkhau@gmail.com) - MIT License # Copyright (c) 2018-2021 Manuel Barkhau (mbarkhau@gmail.com) - MIT License
# SPDX-License-Identifier: MIT # SPDX-License-Identifier: MIT
"""Parse PyCalVer strings from files.""" """Parse PyCalVer strings from files."""

View file

@ -1,7 +1,7 @@
# This file is part of the pycalver project # This file is part of the bumpver project
# https://github.com/mbarkhau/pycalver # https://github.com/mbarkhau/bumpver
# #
# Copyright (c) 2018-2020 Manuel Barkhau (mbarkhau@gmail.com) - MIT License # Copyright (c) 2018-2021 Manuel Barkhau (mbarkhau@gmail.com) - MIT License
# SPDX-License-Identifier: MIT # SPDX-License-Identifier: MIT
import typing as typ import typing as typ

View file

@ -1,7 +1,7 @@
# This file is part of the pycalver project # This file is part of the bumpver project
# https://github.com/mbarkhau/pycalver # https://github.com/mbarkhau/bumpver
# #
# Copyright (c) 2018-2020 Manuel Barkhau (mbarkhau@gmail.com) - MIT License # Copyright (c) 2018-2021 Manuel Barkhau (mbarkhau@gmail.com) - MIT License
# SPDX-License-Identifier: MIT # SPDX-License-Identifier: MIT
import sys import sys
import typing as typ import typing as typ

View file

@ -1,7 +1,7 @@
# This file is part of the pycalver project # This file is part of the bumpver project
# https://github.com/mbarkhau/pycalver # https://github.com/mbarkhau/bumpver
# #
# Copyright (c) 2018-2020 Manuel Barkhau (mbarkhau@gmail.com) - MIT License # Copyright (c) 2018-2021 Manuel Barkhau (mbarkhau@gmail.com) - MIT License
# SPDX-License-Identifier: MIT # SPDX-License-Identifier: MIT
import re import re
import logging import logging

View file

@ -1,7 +1,7 @@
# This file is part of the pycalver project # This file is part of the bumpver project
# https://github.com/mbarkhau/pycalver # https://github.com/mbarkhau/bumpver
# #
# Copyright (c) 2018-2020 Manuel Barkhau (mbarkhau@gmail.com) - MIT License # Copyright (c) 2018-2021 Manuel Barkhau (mbarkhau@gmail.com) - MIT License
# SPDX-License-Identifier: MIT # SPDX-License-Identifier: MIT
import typing as typ import typing as typ
import difflib import difflib

View file

@ -1,7 +1,7 @@
# This file is part of the pycalver project # This file is part of the bumpver project
# https://github.com/mbarkhau/pycalver # https://github.com/mbarkhau/bumpver
# #
# Copyright (c) 2018-2020 Manuel Barkhau (mbarkhau@gmail.com) - MIT License # Copyright (c) 2018-2021 Manuel Barkhau (mbarkhau@gmail.com) - MIT License
# SPDX-License-Identifier: MIT # SPDX-License-Identifier: MIT
import typing as typ import typing as typ
import functools import functools

View file

@ -1,7 +1,7 @@
# This file is part of the pycalver project # This file is part of the bumpver project
# https://github.com/mbarkhau/pycalver # https://github.com/mbarkhau/bumpver
# #
# Copyright (c) 2018-2020 Manuel Barkhau (mbarkhau@gmail.com) - MIT License # Copyright (c) 2018-2021 Manuel Barkhau (mbarkhau@gmail.com) - MIT License
# SPDX-License-Identifier: MIT # SPDX-License-Identifier: MIT
"""Compose Regular Expressions from Patterns. """Compose Regular Expressions from Patterns.

View file

@ -1,7 +1,7 @@
# This file is part of the pycalver project # This file is part of the bumpver project
# https://github.com/mbarkhau/pycalver # https://github.com/mbarkhau/bumpver
# #
# Copyright (c) 2018-2020 Manuel Barkhau (mbarkhau@gmail.com) - MIT License # Copyright (c) 2018-2021 Manuel Barkhau (mbarkhau@gmail.com) - MIT License
# SPDX-License-Identifier: MIT # SPDX-License-Identifier: MIT
"""Rewrite files, updating occurences of version strings.""" """Rewrite files, updating occurences of version strings."""

View file

@ -1,7 +1,7 @@
# This file is part of the pycalver project # This file is part of the bumpver project
# https://github.com/mbarkhau/pycalver # https://github.com/mbarkhau/bumpver
# #
# Copyright (c) 2018-2020 Manuel Barkhau (mbarkhau@gmail.com) - MIT License # Copyright (c) 2018-2021 Manuel Barkhau (mbarkhau@gmail.com) - MIT License
# SPDX-License-Identifier: MIT # SPDX-License-Identifier: MIT
"""Functions related to version string manipulation.""" """Functions related to version string manipulation."""

View file

@ -1,7 +1,7 @@
# This file is part of the pycalver project # This file is part of the bumpver project
# https://github.com/mbarkhau/pycalver # https://github.com/mbarkhau/bumpver
# #
# Copyright (c) 2018-2020 Manuel Barkhau (mbarkhau@gmail.com) - MIT License # Copyright (c) 2018-2021 Manuel Barkhau (mbarkhau@gmail.com) - MIT License
# SPDX-License-Identifier: MIT # SPDX-License-Identifier: MIT
"""Compose Regular Expressions from Patterns. """Compose Regular Expressions from Patterns.

View file

@ -1,7 +1,7 @@
# This file is part of the pycalver project # This file is part of the bumpver project
# https://github.com/mbarkhau/pycalver # https://github.com/mbarkhau/bumpver
# #
# Copyright (c) 2018-2020 Manuel Barkhau (mbarkhau@gmail.com) - MIT License # Copyright (c) 2018-2021 Manuel Barkhau (mbarkhau@gmail.com) - MIT License
# SPDX-License-Identifier: MIT # SPDX-License-Identifier: MIT
"""Rewrite files, updating occurences of version strings.""" """Rewrite files, updating occurences of version strings."""

View file

@ -1,7 +1,7 @@
# This file is part of the pycalver project # This file is part of the bumpver project
# https://github.com/mbarkhau/pycalver # https://github.com/mbarkhau/bumpver
# #
# Copyright (c) 2018-2020 Manuel Barkhau (mbarkhau@gmail.com) - MIT License # Copyright (c) 2018-2021 Manuel Barkhau (mbarkhau@gmail.com) - MIT License
# SPDX-License-Identifier: MIT # SPDX-License-Identifier: MIT
"""Functions related to version string manipulation.""" """Functions related to version string manipulation."""
@ -754,6 +754,11 @@ def incr(
else: else:
cur_vinfo = old_vinfo._replace(**cur_cinfo._asdict()) cur_vinfo = old_vinfo._replace(**cur_cinfo._asdict())
has_tag_part = cur_vinfo.tag != "final"
if tag_num and not tag and not has_tag_part:
logger.error("Invalid arguments, non-final --tag=<tag> is needed to use --tag-num.")
return None
cur_vinfo = _incr_numeric( cur_vinfo = _incr_numeric(
raw_pattern, raw_pattern,
old_vinfo, old_vinfo,

View file

@ -1,7 +1,7 @@
# This file is part of the pycalver project # This file is part of the bumpver project
# https://github.com/mbarkhau/pycalver # https://github.com/mbarkhau/bumpver
# #
# Copyright (c) 2018-2020 Manuel Barkhau (mbarkhau@gmail.com) - MIT License # Copyright (c) 2018-2021 Manuel Barkhau (mbarkhau@gmail.com) - MIT License
# SPDX-License-Identifier: MIT # SPDX-License-Identifier: MIT
# #
# bumpver/vcs.py (this file) is based on code from the # bumpver/vcs.py (this file) is based on code from the

View file

@ -1,7 +1,7 @@
# This file is part of the pycalver project # This file is part of the bumpver project
# https://github.com/mbarkhau/pycalver # https://github.com/mbarkhau/bumpver
# #
# Copyright (c) 2018-2020 Manuel Barkhau (mbarkhau@gmail.com) - MIT License # Copyright (c) 2018-2021 Manuel Barkhau (mbarkhau@gmail.com) - MIT License
# SPDX-License-Identifier: MIT # SPDX-License-Identifier: MIT
import typing as typ import typing as typ
import datetime as dt import datetime as dt

View file

@ -116,6 +116,17 @@ def test_version(runner):
assert match assert match
def test_show_env(runner):
_add_project_files("README.md", "setup.cfg")
result = runner.invoke(cli.cli, ['init', "-vv"])
assert result.exit_code == 0
result = runner.invoke(cli.cli, ['show', "-e"])
assert result.exit_code == 0
assert "TAG=alpha" in result.output
def test_incr_default(runner): def test_incr_default(runner):
old_version = "v201709.1004-alpha" old_version = "v201709.1004-alpha"

View file

@ -227,10 +227,10 @@ def test_v1_iter_rewritten():
rewritten_datas = v1rewrite.iter_rewritten(file_patterns, new_vinfo) rewritten_datas = v1rewrite.iter_rewritten(file_patterns, new_vinfo)
rfd = list(rewritten_datas)[0] rfd = list(rewritten_datas)[0]
expected = [ expected = [
"# This file is part of the pycalver project", "# This file is part of the bumpver project",
"# https://github.com/mbarkhau/pycalver", "# https://github.com/mbarkhau/bumpver",
"#", "#",
"# Copyright (c) 2018-2020 Manuel Barkhau (mbarkhau@gmail.com) - MIT License", "# Copyright (c) 2018-2021 Manuel Barkhau (mbarkhau@gmail.com) - MIT License",
"# SPDX-License-Identifier: MIT", "# SPDX-License-Identifier: MIT",
'"""BumpVer: A CLI program for versioning."""', '"""BumpVer: A CLI program for versioning."""',
'', '',
@ -253,10 +253,10 @@ def test_v2_iter_rewritten():
rewritten_datas = v2rewrite.iter_rewritten(file_patterns, new_vinfo) rewritten_datas = v2rewrite.iter_rewritten(file_patterns, new_vinfo)
rfd = list(rewritten_datas)[0] rfd = list(rewritten_datas)[0]
expected = [ expected = [
"# This file is part of the pycalver project", "# This file is part of the bumpver project",
"# https://github.com/mbarkhau/pycalver", "# https://github.com/mbarkhau/bumpver",
"#", "#",
"# Copyright (c) 2018-2020 Manuel Barkhau (mbarkhau@gmail.com) - MIT License", "# Copyright (c) 2018-2021 Manuel Barkhau (mbarkhau@gmail.com) - MIT License",
"# SPDX-License-Identifier: MIT", "# SPDX-License-Identifier: MIT",
'"""BumpVer: A CLI program for versioning."""', '"""BumpVer: A CLI program for versioning."""',
'', '',

View file

@ -73,6 +73,18 @@ def test_bump_random(monkeypatch):
cur_version = new_version cur_version = new_version
def test_bump_tag_num():
raw_pattern = "MAJOR.MINOR.PATCH[PYTAGNUM]"
cur_version = "0.1.1b0"
assert v2version.incr(cur_version, raw_pattern, tag_num=True) == "0.1.1b1"
def test_bump_tag_num_without_tag():
raw_pattern = "MAJOR.MINOR.PATCH[PYTAGNUM]"
cur_version = "0.1.1"
assert v2version.incr(cur_version, raw_pattern, tag_num=True) is None
def test_parse_version_info(): def test_parse_version_info():
version_str = "v201712.0001-alpha" version_str = "v201712.0001-alpha"
version_info = v1version.parse_version_info(version_str) version_info = v1version.parse_version_info(version_str)