mirror of
https://github.com/TECHNOFAB11/bumpver.git
synced 2025-12-12 14:30:09 +01:00
pycalver -> bumpver
This commit is contained in:
parent
2c01699b99
commit
bbf5bfa31c
35 changed files with 764 additions and 1235 deletions
28
CHANGELOG.md
28
CHANGELOG.md
|
|
@ -1,7 +1,9 @@
|
||||||
# Changelog for https://github.com/mbarkhau/pycalver
|
# Changelog for https://github.com/mbarkhau/pycalver
|
||||||
|
|
||||||
|
|
||||||
## NEXT
|
## BumpVer 2020.1042-beta
|
||||||
|
|
||||||
|
Rename package and module from PyCalVer to BumpVer. This name change is due to confusion that this project is either Python specific, or only suitible for CalVer versioning schemes, neither of which is the case.
|
||||||
|
|
||||||
This release includes a new syntax for patterns.
|
This release includes a new syntax for patterns.
|
||||||
|
|
||||||
|
|
@ -34,7 +36,7 @@ The previous syntax will continue to be supported, but all documentation has bee
|
||||||
- New [gitlab#9][gitlab_i9]: Make commit message configurable.
|
- New [gitlab#9][gitlab_i9]: Make commit message configurable.
|
||||||
- Fix [gitlab#12][gitlab_i12]: Error with sorting non-lexical version tags (e.g. SemVer).
|
- Fix [gitlab#12][gitlab_i12]: Error with sorting non-lexical version tags (e.g. SemVer).
|
||||||
- Fix [gitlab#11][gitlab_i11]: Show regexp when `--verbose` is used.
|
- Fix [gitlab#11][gitlab_i11]: Show regexp when `--verbose` is used.
|
||||||
- Fix [gitlab#8][gitlab_i8]: `pycalver push ` will now also push HEAD (previously only the tag itself was pushed).
|
- Fix [gitlab#8][gitlab_i8]: `bumpver update` will now also push HEAD (previously only the tag itself was pushed).
|
||||||
- Fix: Disallow `--release=dev`. The semantics of a `dev` releases are different than for other release tags and further development would be required to support them correctly.
|
- Fix: Disallow `--release=dev`. The semantics of a `dev` releases are different than for other release tags and further development would be required to support them correctly.
|
||||||
- Fix: Entries in `file_patterns` were ignored if there were multiple entries for the same file.
|
- Fix: Entries in `file_patterns` were ignored if there were multiple entries for the same file.
|
||||||
|
|
||||||
|
|
@ -51,12 +53,12 @@ Many thanks to contributors of this release: @LucidOne, @khanguslee, @chaudum
|
||||||
[gitlab_i8]: https://gitlab.com/mbarkhau/pycalver/-/issues/8
|
[gitlab_i8]: https://gitlab.com/mbarkhau/pycalver/-/issues/8
|
||||||
|
|
||||||
|
|
||||||
## v201907.0036
|
## PyCalVer v201907.0036
|
||||||
|
|
||||||
- Fix: Don't use git/hg command if `commit=False` is configured (thanks @valentin87)
|
- Fix: Don't use git/hg command if `commit=False` is configured (thanks @valentin87)
|
||||||
|
|
||||||
|
|
||||||
## v201907.0035
|
## PyCalVer v201907.0035
|
||||||
|
|
||||||
- Fix [gitlab#6][gitlab_i6]: Add parts `{month_short}`, `{dom_short}`, `{doy_short}`.
|
- Fix [gitlab#6][gitlab_i6]: Add parts `{month_short}`, `{dom_short}`, `{doy_short}`.
|
||||||
- Fix [gitlab#5][gitlab_i5]: Better warning when using bump with SemVer (one of --major/--minor/--patch is required)
|
- Fix [gitlab#5][gitlab_i5]: Better warning when using bump with SemVer (one of --major/--minor/--patch is required)
|
||||||
|
|
@ -67,43 +69,43 @@ Many thanks to contributors of this release: @LucidOne, @khanguslee, @chaudum
|
||||||
[gitlab_i4]: https://gitlab.com/mbarkhau/pycalver/-/issues/4
|
[gitlab_i4]: https://gitlab.com/mbarkhau/pycalver/-/issues/4
|
||||||
|
|
||||||
|
|
||||||
## v201903.0030
|
## PyCalVer v201903.0030
|
||||||
|
|
||||||
- Fix: Use pattern from config instead of hard-coded {pycalver} pattern.
|
- Fix: Use pattern from config instead of hard-coded {pycalver} pattern.
|
||||||
- Fix: Better error messages for git/hg issues.
|
- Fix: Better error messages for git/hg issues.
|
||||||
- Add: Implicit default pattern for config file.
|
- Add: Implicit default pattern for config file.
|
||||||
|
|
||||||
|
|
||||||
## v201903.0028
|
## PyCalVer v201903.0028
|
||||||
|
|
||||||
- Fix: Add warnings when configured files are not under version control.
|
- Fix: Add warnings when configured files are not under version control.
|
||||||
- Add: Colored output for bump --dry
|
- Add: Colored output for bump --dry
|
||||||
|
|
||||||
|
|
||||||
## v201902.0027
|
## PyCalVer v201902.0027
|
||||||
|
|
||||||
- Fix: Allow --release=post
|
- Fix: Allow --release=post
|
||||||
- Fix: Better error reporting for bad patterns
|
- Fix: Better error reporting for bad patterns
|
||||||
- Fix: Regex escaping issue with "?"
|
- Fix: Regex escaping issue with "?"
|
||||||
|
|
||||||
|
|
||||||
## v201902.0024
|
## PyCalVer v201902.0024
|
||||||
|
|
||||||
- Added: Support for globs in file patterns.
|
- Added: Support for globs in file patterns.
|
||||||
- Fixed: Better error reporting for invalid config.
|
- Fixed: Better error reporting for invalid config.
|
||||||
|
|
||||||
|
|
||||||
## v201902.0020
|
## PyCalVer v201902.0020
|
||||||
|
|
||||||
- Added: Support for many more custom version patterns.
|
- Added: Support for many more custom version patterns.
|
||||||
|
|
||||||
|
|
||||||
## v201812.0018
|
## PyCalVer v201812.0018
|
||||||
|
|
||||||
- Fixed: Better handling of pattern replacements with "-final" releases.
|
- Fixed: Better handling of pattern replacements with "-final" releases.
|
||||||
|
|
||||||
|
|
||||||
## v201812.0017
|
## PyCalVer v201812.0017
|
||||||
|
|
||||||
- Fixed [github#2]. `pycalver init` was broken.
|
- Fixed [github#2]. `pycalver init` was broken.
|
||||||
- Fixed pattern escaping issues.
|
- Fixed pattern escaping issues.
|
||||||
|
|
@ -113,7 +115,7 @@ Many thanks to contributors of this release: @LucidOne, @khanguslee, @chaudum
|
||||||
[gihlab_i2]: https://github.com/mbarkhau/pycalver/-/issues/2
|
[gihlab_i2]: https://github.com/mbarkhau/pycalver/-/issues/2
|
||||||
|
|
||||||
|
|
||||||
## v201812.0011-beta
|
## PyCalVer v201812.0011-beta
|
||||||
|
|
||||||
- Add version tags using git/hg.
|
- Add version tags using git/hg.
|
||||||
- Use git/hg tags as SSOT for most recent version.
|
- Use git/hg tags as SSOT for most recent version.
|
||||||
|
|
@ -121,6 +123,6 @@ Many thanks to contributors of this release: @LucidOne, @khanguslee, @chaudum
|
||||||
- Move to https://gitlab.com/mbarkhau/pycalver
|
- Move to https://gitlab.com/mbarkhau/pycalver
|
||||||
|
|
||||||
|
|
||||||
## v201809.0001-alpha
|
## PyCalVer v201809.0001-alpha
|
||||||
|
|
||||||
- Initial release
|
- Initial release
|
||||||
|
|
|
||||||
2
Makefile
2
Makefile
|
|
@ -74,6 +74,6 @@ pycalver_deps.svg:
|
||||||
|
|
||||||
|
|
||||||
## Update cli reference in README.md
|
## Update cli reference in README.md
|
||||||
README.md: src/pycalver/__main__.py scripts/update_readme_examples.py Makefile
|
README.md: src/pycalver2/cli.py scripts/update_readme_examples.py Makefile
|
||||||
@git add README.md
|
@git add README.md
|
||||||
@$(DEV_ENV)/bin/python scripts/update_readme_examples.py
|
@$(DEV_ENV)/bin/python scripts/update_readme_examples.py
|
||||||
|
|
|
||||||
|
|
@ -4,19 +4,19 @@
|
||||||
AUTHOR_NAME="Manuel Barkhau"
|
AUTHOR_NAME="Manuel Barkhau"
|
||||||
AUTHOR_EMAIL="mbarkhau@gmail.com"
|
AUTHOR_EMAIL="mbarkhau@gmail.com"
|
||||||
|
|
||||||
KEYWORDS="version versioning calver semver bumpversion pep440"
|
KEYWORDS="version bumpver calver semver versioning bumpversion pep440"
|
||||||
DESCRIPTION="CalVer for python packages."
|
DESCRIPTION="Bump version numbers in project files."
|
||||||
|
|
||||||
LICENSE_ID="MIT"
|
LICENSE_ID="MIT"
|
||||||
|
|
||||||
PACKAGE_NAME="pycalver"
|
PACKAGE_NAME="bumpver"
|
||||||
GIT_REPO_NAMESPACE="mbarkhau"
|
GIT_REPO_NAMESPACE="mbarkhau"
|
||||||
GIT_REPO_DOMAIN="github.com"
|
GIT_REPO_DOMAIN="github.com"
|
||||||
|
|
||||||
PACKAGE_VERSION="v2020.1041-beta"
|
PACKAGE_VERSION="2020.1041-beta"
|
||||||
|
|
||||||
DEFAULT_PYTHON_VERSION="python=3.8"
|
DEFAULT_PYTHON_VERSION="python=3.8"
|
||||||
SUPPORTED_PYTHON_VERSIONS="python=2.7 python=3.6 python=3.8 pypy2.7 pypy3.5"
|
SUPPORTED_PYTHON_VERSIONS="python=2.7 python=3.6 pypy2.7 pypy3.5 python=3.8"
|
||||||
|
|
||||||
DOCKER_REGISTRY_DOMAIN=registry.gitlab.com
|
DOCKER_REGISTRY_DOMAIN=registry.gitlab.com
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ import rich
|
||||||
import rich.box
|
import rich.box
|
||||||
import rich.table
|
import rich.table
|
||||||
|
|
||||||
from pycalver import v2version
|
from bumpcalver import v2version
|
||||||
|
|
||||||
|
|
||||||
def update(content, marker, value):
|
def update(content, marker, value):
|
||||||
|
|
@ -73,10 +73,10 @@ def pattern_examples():
|
||||||
("MAJOR.MINOR.PATCH[PYTAGNUM]" , ""),
|
("MAJOR.MINOR.PATCH[PYTAGNUM]" , ""),
|
||||||
("MAJOR.MINOR[.PATCH[PYTAGNUM]]", ""),
|
("MAJOR.MINOR[.PATCH[PYTAGNUM]]", ""),
|
||||||
("YYYY.BUILD[PYTAGNUM]" , ""),
|
("YYYY.BUILD[PYTAGNUM]" , ""),
|
||||||
("YYYY.BUILD[-RELEASE]" , ""),
|
("YYYY.BUILD[-TAG]" , ""),
|
||||||
("YYYY.INC0[PYTAGNUM]" , ""),
|
("YYYY.INC0[PYTAGNUM]" , ""),
|
||||||
("YYYY0M.PATCH[-RELEASE]" , "¹"),
|
("YYYY0M.PATCH[-TAG]" , "¹"),
|
||||||
("YYYY0M.BUILD[-RELEASE]" , ""),
|
("YYYY0M.BUILD[-TAG]" , ""),
|
||||||
("YYYY.0M" , ""),
|
("YYYY.0M" , ""),
|
||||||
("YYYY.MM" , ""),
|
("YYYY.MM" , ""),
|
||||||
("YYYY.WW" , ""),
|
("YYYY.WW" , ""),
|
||||||
|
|
@ -184,8 +184,8 @@ def pattern_examples():
|
||||||
old_content = io.open("README.md").read()
|
old_content = io.open("README.md").read()
|
||||||
|
|
||||||
new_content = old_content
|
new_content = old_content
|
||||||
new_content = update_md_code_output(new_content, "calver --help")
|
new_content = update_md_code_output(new_content, "bumpver --help")
|
||||||
new_content = update_md_code_output(new_content, "calver bump --help")
|
new_content = update_md_code_output(new_content, "bumpver update --help")
|
||||||
new_content = update(new_content, "pattern_examples", pattern_examples())
|
new_content = update(new_content, "pattern_examples", pattern_examples())
|
||||||
new_content = update(new_content, "weeknum_example" , weeknum_example())
|
new_content = update(new_content, "weeknum_example" , weeknum_example())
|
||||||
|
|
||||||
|
|
@ -197,20 +197,3 @@ elif "--dry" in sys.argv:
|
||||||
else:
|
else:
|
||||||
with io.open("README.md", mode="w") as fobj:
|
with io.open("README.md", mode="w") as fobj:
|
||||||
fobj.write(new_content)
|
fobj.write(new_content)
|
||||||
|
|
||||||
|
|
||||||
# @printf '\n```\n$$ calver --help\n' > /tmp/pycalver_help.txt
|
|
||||||
# @$(DEV_ENV)/bin/calver --help >> /tmp/pycalver_help.txt
|
|
||||||
# @printf '```\n\n' >> /tmp/pycalver_help.txt
|
|
||||||
|
|
||||||
# sed -i -ne '/<!-- BEGIN pycalver --help -->/ {p; r /tmp/pycalver_help.txt' \
|
|
||||||
# -e ':a; n; /<!-- END pycalver --help -->/ {p; b}; ba}; p' \
|
|
||||||
# README.md
|
|
||||||
|
|
||||||
# @printf '\n```\n$$ pycalver bump --help\n' > /tmp/pycalver_help.txt
|
|
||||||
# @$(DEV_ENV)/bin/pycalver bump --help >> /tmp/pycalver_help.txt
|
|
||||||
# @printf '```\n\n' >> /tmp/pycalver_help.txt
|
|
||||||
|
|
||||||
# sed -i -ne '/<!-- BEGIN pycalver bump --help -->/ {p; r /tmp/pycalver_help.txt' \
|
|
||||||
# -e ':a; n; /<!-- END pycalver bump --help -->/ {p; b}; ba}; p' \
|
|
||||||
# README.md
|
|
||||||
|
|
|
||||||
20
setup.cfg
20
setup.cfg
|
|
@ -19,7 +19,7 @@ warn_redundant_casts = True
|
||||||
|
|
||||||
|
|
||||||
[tool:isort]
|
[tool:isort]
|
||||||
known_first_party = pycalver2
|
known_first_party = bumpver
|
||||||
known_third_party = click,pathlib2,lexid,pkg_resources
|
known_third_party = click,pathlib2,lexid,pkg_resources
|
||||||
force_single_line = True
|
force_single_line = True
|
||||||
length_sort = True
|
length_sort = True
|
||||||
|
|
@ -88,26 +88,26 @@ exclude =
|
||||||
addopts = --doctest-modules
|
addopts = --doctest-modules
|
||||||
|
|
||||||
|
|
||||||
[calver]
|
[bumpver]
|
||||||
current_version = "v2020.1041-beta"
|
current_version = "2020.1041-beta"
|
||||||
version_pattern = "vYYYY.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
|
||||||
tag = True
|
tag = True
|
||||||
push = True
|
push = True
|
||||||
|
|
||||||
[calver:file_patterns]
|
[bumpver:file_patterns]
|
||||||
bootstrapit.sh =
|
bootstrapit.sh =
|
||||||
PACKAGE_VERSION="{version}"
|
PACKAGE_VERSION="{version}"
|
||||||
setup.cfg =
|
setup.cfg =
|
||||||
current_version = "{version}"
|
current_version = "{version}"
|
||||||
setup.py =
|
setup.py =
|
||||||
version="{pep440_version}"
|
version="{pep440_version}",
|
||||||
src/pycalver2/__init__.py =
|
src/bumpver/__init__.py =
|
||||||
__version__ = "{version}"
|
__version__ = "{version}"
|
||||||
src/pycalver2/cli.py =
|
src/bumpver/cli.py =
|
||||||
@click.version_option(version="{version}")
|
@click.version_option(version="{version}")
|
||||||
src/pycalver2*/*.py =
|
src/bumpver/*.py =
|
||||||
Copyright (c) 2018-YYYY
|
Copyright (c) 2018-YYYY
|
||||||
LICENSE =
|
LICENSE =
|
||||||
Copyright (c) 2018-YYYY
|
Copyright (c) 2018-YYYY
|
||||||
|
|
@ -116,7 +116,7 @@ license.header =
|
||||||
README.md =
|
README.md =
|
||||||
\[CalVer {version}\]
|
\[CalVer {version}\]
|
||||||
img.shields.io/static/v1.svg?label=CalVer&message={version}&color=blue
|
img.shields.io/static/v1.svg?label=CalVer&message={version}&color=blue
|
||||||
Successfully installed python-calver-{pep440_version}
|
Successfully installed bumpver-{pep440_version}
|
||||||
|
|
||||||
|
|
||||||
[tool:pylint]
|
[tool:pylint]
|
||||||
|
|
|
||||||
10
setup.py
10
setup.py
|
|
@ -58,14 +58,14 @@ if any(arg.startswith("bdist") for arg in sys.argv):
|
||||||
|
|
||||||
|
|
||||||
setuptools.setup(
|
setuptools.setup(
|
||||||
name="python-calver",
|
name="bumpver",
|
||||||
license="MIT",
|
license="MIT",
|
||||||
author="Manuel Barkhau",
|
author="Manuel Barkhau",
|
||||||
author_email="mbarkhau@gmail.com",
|
author_email="mbarkhau@gmail.com",
|
||||||
url="https://github.com/mbarkhau/pycalver",
|
url="https://github.com/mbarkhau/bumpver",
|
||||||
version="2020.1041b0",
|
version="2020.1041b0",
|
||||||
keywords="version versioning calver semver bumpversion pep440",
|
keywords="version bumpver calver semver versioning bumpversion pep440",
|
||||||
description="CalVer for python libraries.",
|
description="Bump version numbers in project files.",
|
||||||
long_description=long_description,
|
long_description=long_description,
|
||||||
long_description_content_type="text/markdown",
|
long_description_content_type="text/markdown",
|
||||||
packages=setuptools.find_packages("src/"),
|
packages=setuptools.find_packages("src/"),
|
||||||
|
|
@ -73,7 +73,7 @@ setuptools.setup(
|
||||||
install_requires=install_requires,
|
install_requires=install_requires,
|
||||||
entry_points="""
|
entry_points="""
|
||||||
[console_scripts]
|
[console_scripts]
|
||||||
calver=pycalver2.cli:cli
|
bumpver=bumpver.cli:cli
|
||||||
""",
|
""",
|
||||||
python_requires=">=2.7",
|
python_requires=">=2.7",
|
||||||
zip_safe=True,
|
zip_safe=True,
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,6 @@
|
||||||
#
|
#
|
||||||
# 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
|
||||||
"""PyCalVer: CalVer for Python Packages."""
|
"""BumpVer: A CLI program for versioning."""
|
||||||
|
|
||||||
__version__ = "v2020.1041-beta"
|
__version__ = "2020.1041-beta"
|
||||||
|
|
@ -5,9 +5,9 @@
|
||||||
# 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
|
||||||
"""
|
"""
|
||||||
__main__ module for PyCalVer.
|
__main__ module for BumpVer.
|
||||||
|
|
||||||
Enables use as module: $ python -m pycalver --version
|
Enables use as module: $ python -m bumpver --version
|
||||||
"""
|
"""
|
||||||
from . import cli
|
from . import cli
|
||||||
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
#
|
#
|
||||||
# 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
|
||||||
"""cli module for PyCalVer."""
|
"""cli module for BumpVer."""
|
||||||
import io
|
import io
|
||||||
import sys
|
import sys
|
||||||
import typing as typ
|
import typing as typ
|
||||||
|
|
@ -39,7 +39,7 @@ except ImportError:
|
||||||
|
|
||||||
click.disable_unicode_literals_warning = True
|
click.disable_unicode_literals_warning = True
|
||||||
|
|
||||||
logger = logging.getLogger("pycalver2.cli")
|
logger = logging.getLogger("bumpver.cli")
|
||||||
|
|
||||||
|
|
||||||
_VERBOSE = 0
|
_VERBOSE = 0
|
||||||
|
|
@ -140,7 +140,7 @@ def _log_no_change(subcmd: str, version_pattern: str, old_version: str) -> None:
|
||||||
]
|
]
|
||||||
if available_flags:
|
if available_flags:
|
||||||
available_flags_str = "/".join(available_flags)
|
available_flags_str = "/".join(available_flags)
|
||||||
logger.info(f"Perhaps try: calver {subcmd} {available_flags_str} ")
|
logger.info(f"Perhaps try: bumpver {subcmd} {available_flags_str} ")
|
||||||
|
|
||||||
|
|
||||||
def _get_normalized_pattern(raw_pattern: str, version_pattern: typ.Optional[str]) -> str:
|
def _get_normalized_pattern(raw_pattern: str, version_pattern: typ.Optional[str]) -> str:
|
||||||
|
|
@ -164,7 +164,7 @@ def _get_normalized_pattern(raw_pattern: str, version_pattern: typ.Optional[str]
|
||||||
|
|
||||||
|
|
||||||
@click.group()
|
@click.group()
|
||||||
@click.version_option(version="v2020.1041-beta")
|
@click.version_option(version="2020.1041-beta")
|
||||||
@click.help_option()
|
@click.help_option()
|
||||||
@click.option('-v', '--verbose', count=True, help="Control log level. -vv for debug level.")
|
@click.option('-v', '--verbose', count=True, help="Control log level. -vv for debug level.")
|
||||||
def cli(verbose: int = 0) -> None:
|
def cli(verbose: int = 0) -> None:
|
||||||
|
|
@ -241,6 +241,7 @@ def test(
|
||||||
pep440_version = version.to_pep440(new_version)
|
pep440_version = version.to_pep440(new_version)
|
||||||
|
|
||||||
click.echo(f"New Version: {new_version}")
|
click.echo(f"New Version: {new_version}")
|
||||||
|
if new_version != pep440_version:
|
||||||
click.echo(f"PEP440 : {pep440_version}")
|
click.echo(f"PEP440 : {pep440_version}")
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -292,6 +293,7 @@ def _grep(
|
||||||
|
|
||||||
match_strs = list(_grep_text(pattern, text, color))
|
match_strs = list(_grep_text(pattern, text, color))
|
||||||
if len(match_strs) > 0:
|
if len(match_strs) > 0:
|
||||||
|
if len(file_ios) > 1:
|
||||||
print(file_io.name)
|
print(file_io.name)
|
||||||
for match_str in match_strs:
|
for match_str in match_strs:
|
||||||
print(match_str)
|
print(match_str)
|
||||||
|
|
@ -365,7 +367,7 @@ def show(verbose: int = 0, fetch: bool = True) -> None:
|
||||||
_, cfg = config.init(project_path=".")
|
_, cfg = config.init(project_path=".")
|
||||||
|
|
||||||
if cfg is None:
|
if cfg is None:
|
||||||
logger.error("Could not parse configuration. Perhaps try 'calver init'.")
|
logger.error("Could not parse configuration. Perhaps try 'bumpver init'.")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
cfg = _update_cfg_from_vcs(cfg, fetch)
|
cfg = _update_cfg_from_vcs(cfg, fetch)
|
||||||
|
|
@ -418,6 +420,9 @@ def _print_diff(cfg: config.Config, new_version: str) -> None:
|
||||||
try:
|
try:
|
||||||
diff = get_diff(cfg, new_version)
|
diff = get_diff(cfg, new_version)
|
||||||
_print_diff_str(diff)
|
_print_diff_str(diff)
|
||||||
|
except OSError as err:
|
||||||
|
logger.error(str(err))
|
||||||
|
sys.exit(1)
|
||||||
except rewrite.NoPatternMatch as ex:
|
except rewrite.NoPatternMatch as ex:
|
||||||
logger.error(str(ex))
|
logger.error(str(ex))
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
@ -482,7 +487,7 @@ def incr_dispatch(
|
||||||
return new_version
|
return new_version
|
||||||
|
|
||||||
|
|
||||||
def _bump(
|
def _update(
|
||||||
cfg : config.Config,
|
cfg : config.Config,
|
||||||
new_version : str,
|
new_version : str,
|
||||||
commit_message: str,
|
commit_message: str,
|
||||||
|
|
@ -516,14 +521,14 @@ def _bump(
|
||||||
vcs.commit(cfg, vcs_api, filepaths, new_version, commit_message)
|
vcs.commit(cfg, vcs_api, filepaths, new_version, commit_message)
|
||||||
|
|
||||||
|
|
||||||
def _try_bump(
|
def _try_update(
|
||||||
cfg : config.Config,
|
cfg : config.Config,
|
||||||
new_version : str,
|
new_version : str,
|
||||||
commit_message: str,
|
commit_message: str,
|
||||||
allow_dirty : bool = False,
|
allow_dirty : bool = False,
|
||||||
) -> None:
|
) -> None:
|
||||||
try:
|
try:
|
||||||
_bump(cfg, new_version, commit_message, allow_dirty)
|
_update(cfg, new_version, commit_message, allow_dirty)
|
||||||
except sp.CalledProcessError as ex:
|
except sp.CalledProcessError as ex:
|
||||||
logger.error(f"Error running subcommand: {ex.cmd}")
|
logger.error(f"Error running subcommand: {ex.cmd}")
|
||||||
if ex.stdout:
|
if ex.stdout:
|
||||||
|
|
@ -650,7 +655,7 @@ def _update_cfg_from_vcs(cfg: config.Config, fetch: bool) -> config.Config:
|
||||||
metavar="<ISODATE>",
|
metavar="<ISODATE>",
|
||||||
help=f"Set explicit date in format YYYY-0M-0D (e.g. {_current_date}).",
|
help=f"Set explicit date in format YYYY-0M-0D (e.g. {_current_date}).",
|
||||||
)
|
)
|
||||||
def bump(
|
def update(
|
||||||
verbose : int = 0,
|
verbose : int = 0,
|
||||||
dry : bool = False,
|
dry : bool = False,
|
||||||
allow_dirty: bool = False,
|
allow_dirty: bool = False,
|
||||||
|
|
@ -663,7 +668,7 @@ def bump(
|
||||||
pin_date : bool = False,
|
pin_date : bool = False,
|
||||||
date : typ.Optional[str] = None,
|
date : typ.Optional[str] = None,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Increment the current version string and update project files."""
|
"""Update project files with the incremented version string."""
|
||||||
verbose = max(_VERBOSE, verbose)
|
verbose = max(_VERBOSE, verbose)
|
||||||
_configure_logging(verbose)
|
_configure_logging(verbose)
|
||||||
_validate_release_tag(tag)
|
_validate_release_tag(tag)
|
||||||
|
|
@ -672,7 +677,7 @@ def bump(
|
||||||
_, cfg = config.init(project_path=".")
|
_, cfg = config.init(project_path=".")
|
||||||
|
|
||||||
if cfg is None:
|
if cfg is None:
|
||||||
logger.error("Could not parse configuration. Perhaps try 'pycalver init'.")
|
logger.error("Could not parse configuration. Perhaps try 'bumpver init'.")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
cfg = _update_cfg_from_vcs(cfg, fetch)
|
cfg = _update_cfg_from_vcs(cfg, fetch)
|
||||||
|
|
@ -691,7 +696,7 @@ def bump(
|
||||||
)
|
)
|
||||||
|
|
||||||
if new_version is None:
|
if new_version is None:
|
||||||
_log_no_change('bump', cfg.version_pattern, old_version)
|
_log_no_change('update', cfg.version_pattern, old_version)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
logger.info(f"Old Version: {old_version}")
|
logger.info(f"Old Version: {old_version}")
|
||||||
|
|
@ -711,7 +716,7 @@ def bump(
|
||||||
}
|
}
|
||||||
commit_message = cfg.commit_message.format(**commit_message_kwargs)
|
commit_message = cfg.commit_message.format(**commit_message_kwargs)
|
||||||
|
|
||||||
_try_bump(cfg, new_version, commit_message, allow_dirty)
|
_try_update(cfg, new_version, commit_message, allow_dirty)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
#
|
#
|
||||||
# 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
|
||||||
"""Parse setup.cfg or pycalver.cfg files."""
|
"""Parse bumpver.toml, setup.cfg or pyproject.toml files."""
|
||||||
|
|
||||||
import re
|
import re
|
||||||
import glob
|
import glob
|
||||||
|
|
@ -22,7 +22,7 @@ from . import v1patterns
|
||||||
from . import v2patterns
|
from . import v2patterns
|
||||||
from .patterns import Pattern
|
from .patterns import Pattern
|
||||||
|
|
||||||
logger = logging.getLogger("pycalver2.config")
|
logger = logging.getLogger("bumpver.config")
|
||||||
|
|
||||||
RawPatterns = typ.List[str]
|
RawPatterns = typ.List[str]
|
||||||
RawPatternsByFile = typ.Dict[str, RawPatterns]
|
RawPatternsByFile = typ.Dict[str, RawPatterns]
|
||||||
|
|
@ -32,7 +32,7 @@ PatternsByFile = typ.Dict[str, typ.List[Pattern]]
|
||||||
FilePatternsItem = typ.Tuple[str, typ.List[Pattern]]
|
FilePatternsItem = typ.Tuple[str, typ.List[Pattern]]
|
||||||
|
|
||||||
|
|
||||||
SUPPORTED_CONFIGS = ["setup.cfg", "pyproject.toml", "pycalver.toml", "calver.toml"]
|
SUPPORTED_CONFIGS = ["setup.cfg", "pyproject.toml", "pycalver.toml", "bumpver.toml"]
|
||||||
|
|
||||||
DEFAULT_COMMIT_MESSAGE = "bump version to {new_version}"
|
DEFAULT_COMMIT_MESSAGE = "bump version to {new_version}"
|
||||||
|
|
||||||
|
|
@ -51,8 +51,8 @@ def _parse_config_and_format(path: pl.Path) -> typ.Tuple[pl.Path, str, str]:
|
||||||
if (path / "pycalver.toml").exists():
|
if (path / "pycalver.toml").exists():
|
||||||
config_filepath = path / "pycalver.toml"
|
config_filepath = path / "pycalver.toml"
|
||||||
config_format = 'toml'
|
config_format = 'toml'
|
||||||
elif (path / "calver.toml").exists():
|
elif (path / "bumpver.toml").exists():
|
||||||
config_filepath = path / "calver.toml"
|
config_filepath = path / "bumpver.toml"
|
||||||
config_format = 'toml'
|
config_format = 'toml'
|
||||||
elif (path / "pyproject.toml").exists():
|
elif (path / "pyproject.toml").exists():
|
||||||
config_filepath = path / "pyproject.toml"
|
config_filepath = path / "pyproject.toml"
|
||||||
|
|
@ -61,8 +61,8 @@ def _parse_config_and_format(path: pl.Path) -> typ.Tuple[pl.Path, str, str]:
|
||||||
config_filepath = path / "setup.cfg"
|
config_filepath = path / "setup.cfg"
|
||||||
config_format = 'cfg'
|
config_format = 'cfg'
|
||||||
else:
|
else:
|
||||||
# fallback to creating a new calver.toml
|
# fallback to creating a new bumpver.toml
|
||||||
config_filepath = path / "calver.toml"
|
config_filepath = path / "bumpver.toml"
|
||||||
config_format = 'toml'
|
config_format = 'toml'
|
||||||
|
|
||||||
if config_filepath.is_absolute():
|
if config_filepath.is_absolute():
|
||||||
|
|
@ -150,8 +150,8 @@ def _parse_cfg_file_patterns(
|
||||||
|
|
||||||
if cfg_parser.has_section("pycalver:file_patterns"):
|
if cfg_parser.has_section("pycalver:file_patterns"):
|
||||||
file_pattern_items = cfg_parser.items("pycalver:file_patterns")
|
file_pattern_items = cfg_parser.items("pycalver:file_patterns")
|
||||||
elif cfg_parser.has_section("calver:file_patterns"):
|
elif cfg_parser.has_section("bumpver:file_patterns"):
|
||||||
file_pattern_items = cfg_parser.items("calver:file_patterns")
|
file_pattern_items = cfg_parser.items("bumpver:file_patterns")
|
||||||
else:
|
else:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
@ -191,10 +191,10 @@ def _parse_cfg(cfg_buffer: typ.IO[str]) -> RawConfig:
|
||||||
raw_cfg: RawConfig
|
raw_cfg: RawConfig
|
||||||
if cfg_parser.has_section("pycalver"):
|
if cfg_parser.has_section("pycalver"):
|
||||||
raw_cfg = dict(cfg_parser.items("pycalver"))
|
raw_cfg = dict(cfg_parser.items("pycalver"))
|
||||||
elif cfg_parser.has_section("calver"):
|
elif cfg_parser.has_section("bumpver"):
|
||||||
raw_cfg = dict(cfg_parser.items("calver"))
|
raw_cfg = dict(cfg_parser.items("bumpver"))
|
||||||
else:
|
else:
|
||||||
raise ValueError("Missing [calver] section.")
|
raise ValueError("Missing [bumpver] section.")
|
||||||
|
|
||||||
for option, default_val in BOOL_OPTIONS.items():
|
for option, default_val in BOOL_OPTIONS.items():
|
||||||
val: OptionVal = raw_cfg.get(option, default_val)
|
val: OptionVal = raw_cfg.get(option, default_val)
|
||||||
|
|
@ -213,10 +213,10 @@ def _parse_toml(cfg_buffer: typ.IO[str]) -> RawConfig:
|
||||||
raw_full_cfg: typ.Any = toml.load(cfg_buffer)
|
raw_full_cfg: typ.Any = toml.load(cfg_buffer)
|
||||||
raw_cfg : RawConfig
|
raw_cfg : RawConfig
|
||||||
|
|
||||||
if 'pycalver' in raw_full_cfg:
|
if 'bumpver' in raw_full_cfg:
|
||||||
|
raw_cfg = raw_full_cfg['bumpver']
|
||||||
|
elif 'pycalver' in raw_full_cfg:
|
||||||
raw_cfg = raw_full_cfg['pycalver']
|
raw_cfg = raw_full_cfg['pycalver']
|
||||||
elif 'calver' in raw_full_cfg:
|
|
||||||
raw_cfg = raw_full_cfg['calver']
|
|
||||||
else:
|
else:
|
||||||
raw_cfg = {}
|
raw_cfg = {}
|
||||||
|
|
||||||
|
|
@ -297,10 +297,18 @@ def _validate_version_with_pattern(
|
||||||
is_new_pattern : bool,
|
is_new_pattern : bool,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Provoke ValueError if version_pattern and current_version are not compatible."""
|
"""Provoke ValueError if version_pattern and current_version are not compatible."""
|
||||||
|
try:
|
||||||
if is_new_pattern:
|
if is_new_pattern:
|
||||||
v2version.parse_version_info(current_version, version_pattern)
|
v2version.parse_version_info(current_version, version_pattern)
|
||||||
else:
|
else:
|
||||||
v1version.parse_version_info(current_version, version_pattern)
|
v1version.parse_version_info(current_version, version_pattern)
|
||||||
|
except version.PatternError:
|
||||||
|
errmsg = (
|
||||||
|
"Invalid configuration. "
|
||||||
|
f"current_version='{current_version}' is invalid for "
|
||||||
|
f"version_pattern='{version_pattern}'"
|
||||||
|
)
|
||||||
|
raise ValueError(errmsg)
|
||||||
|
|
||||||
if is_new_pattern:
|
if is_new_pattern:
|
||||||
invalid_chars = re.search(r"([\s]+)", version_pattern)
|
invalid_chars = re.search(r"([\s]+)", version_pattern)
|
||||||
|
|
@ -328,6 +336,7 @@ def _parse_config(raw_cfg: RawConfig) -> Config:
|
||||||
version_pattern = raw_cfg['version_pattern'] = version_pattern.strip("'\" ")
|
version_pattern = raw_cfg['version_pattern'] = version_pattern.strip("'\" ")
|
||||||
|
|
||||||
is_new_pattern = "{" not in version_pattern and "}" not in version_pattern
|
is_new_pattern = "{" not in version_pattern and "}" not in version_pattern
|
||||||
|
|
||||||
_validate_version_with_pattern(current_version, version_pattern, is_new_pattern)
|
_validate_version_with_pattern(current_version, version_pattern, is_new_pattern)
|
||||||
|
|
||||||
pep440_version = version.to_pep440(current_version)
|
pep440_version = version.to_pep440(current_version)
|
||||||
|
|
@ -365,19 +374,19 @@ def _parse_config(raw_cfg: RawConfig) -> Config:
|
||||||
|
|
||||||
|
|
||||||
def _parse_current_version_default_pattern(raw_cfg: RawConfig, raw_cfg_text: str) -> str:
|
def _parse_current_version_default_pattern(raw_cfg: RawConfig, raw_cfg_text: str) -> str:
|
||||||
is_pycalver_section = False
|
is_config_section = False
|
||||||
for line in raw_cfg_text.splitlines():
|
for line in raw_cfg_text.splitlines():
|
||||||
if is_pycalver_section and line.startswith("current_version"):
|
if is_config_section and line.startswith("current_version"):
|
||||||
current_version: str = raw_cfg['current_version']
|
current_version: str = raw_cfg['current_version']
|
||||||
version_pattern: str = raw_cfg['version_pattern']
|
version_pattern: str = raw_cfg['version_pattern']
|
||||||
return line.replace(current_version, version_pattern)
|
return line.replace(current_version, version_pattern)
|
||||||
|
|
||||||
if line.strip() == "[pycalver]":
|
if line.strip() == "[pycalver]":
|
||||||
is_pycalver_section = True
|
is_config_section = True
|
||||||
elif line.strip() == "[calver]":
|
elif line.strip() == "[bumpver]":
|
||||||
is_pycalver_section = True
|
is_config_section = True
|
||||||
elif line and line[0] == "[" and line[-1] == "]":
|
elif line and line[0] == "[" and line[-1] == "]":
|
||||||
is_pycalver_section = False
|
is_config_section = False
|
||||||
|
|
||||||
raise ValueError("Could not parse 'current_version'")
|
raise ValueError("Could not parse 'current_version'")
|
||||||
|
|
||||||
|
|
@ -449,15 +458,15 @@ def init(
|
||||||
|
|
||||||
|
|
||||||
DEFAULT_CONFIGPARSER_BASE_TMPL = """
|
DEFAULT_CONFIGPARSER_BASE_TMPL = """
|
||||||
[calver]
|
[bumpver]
|
||||||
current_version = "{initial_version}"
|
current_version = "{initial_version}"
|
||||||
version_pattern = "vYYYY.BUILD[-TAG]"
|
version_pattern = "YYYY.BUILD[-TAG]"
|
||||||
commit_message = "bump version {{old_version}} -> {{new_version}}"
|
commit_message = "bump version {{old_version}} -> {{new_version}}"
|
||||||
commit = True
|
commit = True
|
||||||
tag = True
|
tag = True
|
||||||
push = True
|
push = True
|
||||||
|
|
||||||
[calver:file_patterns]
|
[bumpver:file_patterns]
|
||||||
""".lstrip()
|
""".lstrip()
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -489,15 +498,15 @@ README.md =
|
||||||
|
|
||||||
|
|
||||||
DEFAULT_TOML_BASE_TMPL = """
|
DEFAULT_TOML_BASE_TMPL = """
|
||||||
[calver]
|
[bumpver]
|
||||||
current_version = "{initial_version}"
|
current_version = "{initial_version}"
|
||||||
version_pattern = "vYYYY.BUILD[-TAG]"
|
version_pattern = "YYYY.BUILD[-TAG]"
|
||||||
commit_message = "bump version {{old_version}} -> {{new_version}}"
|
commit_message = "bump version {{old_version}} -> {{new_version}}"
|
||||||
commit = true
|
commit = true
|
||||||
tag = true
|
tag = true
|
||||||
push = true
|
push = true
|
||||||
|
|
||||||
[calver.file_patterns]
|
[bumpver.file_patterns]
|
||||||
""".lstrip()
|
""".lstrip()
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -508,8 +517,8 @@ DEFAULT_TOML_PYCALVER_STR = """
|
||||||
""".lstrip()
|
""".lstrip()
|
||||||
|
|
||||||
|
|
||||||
DEFAULT_TOML_CALVER_STR = """
|
DEFAULT_TOML_BUMPVER_STR = """
|
||||||
"calver.toml" = [
|
"bumpver.toml" = [
|
||||||
'current_version = "{version}"',
|
'current_version = "{version}"',
|
||||||
]
|
]
|
||||||
""".lstrip()
|
""".lstrip()
|
||||||
|
|
@ -547,7 +556,7 @@ DEFAULT_TOML_README_MD_STR = """
|
||||||
|
|
||||||
|
|
||||||
def _initial_version() -> str:
|
def _initial_version() -> str:
|
||||||
return dt.datetime.utcnow().strftime("v%Y.1001-alpha")
|
return dt.datetime.utcnow().strftime("%Y.1001-alpha")
|
||||||
|
|
||||||
|
|
||||||
def _initial_version_pep440() -> str:
|
def _initial_version_pep440() -> str:
|
||||||
|
|
@ -572,7 +581,7 @@ def default_config(ctx: ProjectContext) -> str:
|
||||||
default_pattern_strs_by_filename = {
|
default_pattern_strs_by_filename = {
|
||||||
"pyproject.toml": DEFAULT_TOML_PYPROJECT_STR,
|
"pyproject.toml": DEFAULT_TOML_PYPROJECT_STR,
|
||||||
"pycalver.toml" : DEFAULT_TOML_PYCALVER_STR,
|
"pycalver.toml" : DEFAULT_TOML_PYCALVER_STR,
|
||||||
"calver.toml" : DEFAULT_TOML_CALVER_STR,
|
"bumpver.toml" : DEFAULT_TOML_BUMPVER_STR,
|
||||||
"setup.py" : DEFAULT_TOML_SETUP_PY_STR,
|
"setup.py" : DEFAULT_TOML_SETUP_PY_STR,
|
||||||
"README.rst" : DEFAULT_TOML_README_RST_STR,
|
"README.rst" : DEFAULT_TOML_README_RST_STR,
|
||||||
"README.md" : DEFAULT_TOML_README_MD_STR,
|
"README.md" : DEFAULT_TOML_README_MD_STR,
|
||||||
|
|
@ -592,7 +601,7 @@ def default_config(ctx: ProjectContext) -> str:
|
||||||
if ctx.config_format == 'cfg':
|
if ctx.config_format == 'cfg':
|
||||||
cfg_str += DEFAULT_CONFIGPARSER_SETUP_CFG_STR
|
cfg_str += DEFAULT_CONFIGPARSER_SETUP_CFG_STR
|
||||||
if ctx.config_format == 'toml':
|
if ctx.config_format == 'toml':
|
||||||
cfg_str += DEFAULT_TOML_CALVER_STR
|
cfg_str += DEFAULT_TOML_BUMPVER_STR
|
||||||
|
|
||||||
cfg_str += "\n"
|
cfg_str += "\n"
|
||||||
|
|
||||||
|
|
@ -9,7 +9,7 @@ import textwrap
|
||||||
|
|
||||||
from . import pysix
|
from . import pysix
|
||||||
|
|
||||||
logger = logging.getLogger("pycalver2.regexfmt")
|
logger = logging.getLogger("bumpver.regexfmt")
|
||||||
|
|
||||||
|
|
||||||
def format_regex(regex: str) -> str:
|
def format_regex(regex: str) -> str:
|
||||||
|
|
@ -38,7 +38,7 @@ from . import utils
|
||||||
from .patterns import RE_PATTERN_ESCAPES
|
from .patterns import RE_PATTERN_ESCAPES
|
||||||
from .patterns import Pattern
|
from .patterns import Pattern
|
||||||
|
|
||||||
logger = logging.getLogger("pycalver2.v1patterns")
|
logger = logging.getLogger("bumpver.v1patterns")
|
||||||
|
|
||||||
# https://regex101.com/r/fnj60p/10
|
# https://regex101.com/r/fnj60p/10
|
||||||
PYCALVER_PATTERN = r"""
|
PYCALVER_PATTERN = r"""
|
||||||
|
|
@ -17,7 +17,7 @@ from . import regexfmt
|
||||||
from . import v1version
|
from . import v1version
|
||||||
from .patterns import Pattern
|
from .patterns import Pattern
|
||||||
|
|
||||||
logger = logging.getLogger("pycalver2.v1rewrite")
|
logger = logging.getLogger("bumpver.v1rewrite")
|
||||||
|
|
||||||
|
|
||||||
def rewrite_lines(
|
def rewrite_lines(
|
||||||
|
|
@ -14,7 +14,7 @@ import lexid
|
||||||
from . import version
|
from . import version
|
||||||
from . import v1patterns
|
from . import v1patterns
|
||||||
|
|
||||||
logger = logging.getLogger("pycalver2.v1version")
|
logger = logging.getLogger("bumpver.v1version")
|
||||||
|
|
||||||
|
|
||||||
CalInfo = typ.Union[version.V1CalendarInfo, version.V1VersionInfo]
|
CalInfo = typ.Union[version.V1CalendarInfo, version.V1VersionInfo]
|
||||||
|
|
@ -37,7 +37,7 @@ from . import utils
|
||||||
from .patterns import RE_PATTERN_ESCAPES
|
from .patterns import RE_PATTERN_ESCAPES
|
||||||
from .patterns import Pattern
|
from .patterns import Pattern
|
||||||
|
|
||||||
logger = logging.getLogger("pycalver2.v2patterns")
|
logger = logging.getLogger("bumpver.v2patterns")
|
||||||
|
|
||||||
# NOTE (mb 2020-09-17): For patterns with different options '(AAA|BB|C)', the
|
# NOTE (mb 2020-09-17): For patterns with different options '(AAA|BB|C)', the
|
||||||
# patterns with more digits should be first/left of those with fewer digits:
|
# patterns with more digits should be first/left of those with fewer digits:
|
||||||
|
|
@ -248,6 +248,8 @@ def _convert_to_pep440(version_pattern: str) -> str:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
substitution = PEP440_PART_SUBSTITUTIONS[part_name]
|
substitution = PEP440_PART_SUBSTITUTIONS[part_name]
|
||||||
|
if substitution in pep440_pattern:
|
||||||
|
continue
|
||||||
|
|
||||||
is_numerical_part = part_name not in ('TAG', 'PYTAG')
|
is_numerical_part = part_name not in ('TAG', 'PYTAG')
|
||||||
if is_numerical_part:
|
if is_numerical_part:
|
||||||
|
|
@ -18,7 +18,7 @@ from . import v2version
|
||||||
from . import v2patterns
|
from . import v2patterns
|
||||||
from .patterns import Pattern
|
from .patterns import Pattern
|
||||||
|
|
||||||
logger = logging.getLogger("pycalver2.v2rewrite")
|
logger = logging.getLogger("bumpver.v2rewrite")
|
||||||
|
|
||||||
|
|
||||||
def rewrite_lines(
|
def rewrite_lines(
|
||||||
|
|
@ -14,7 +14,7 @@ import lexid
|
||||||
from . import version
|
from . import version
|
||||||
from . import v2patterns
|
from . import v2patterns
|
||||||
|
|
||||||
logger = logging.getLogger("pycalver2.v2version")
|
logger = logging.getLogger("bumpver.v2version")
|
||||||
|
|
||||||
|
|
||||||
CalInfo = typ.Union[version.V2CalendarInfo, version.V2VersionInfo]
|
CalInfo = typ.Union[version.V2CalendarInfo, version.V2VersionInfo]
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
# 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
|
||||||
#
|
#
|
||||||
# pycalver2/vcs.py (this file) is based on code from the
|
# bumpver/vcs.py (this file) is based on code from the
|
||||||
# bumpversion project: https://github.com/peritus/bumpversion
|
# bumpversion project: https://github.com/peritus/bumpversion
|
||||||
# Copyright (c) 2013-2014 Filip Noetzel - MIT License
|
# Copyright (c) 2013-2014 Filip Noetzel - MIT License
|
||||||
|
|
||||||
|
|
@ -25,7 +25,7 @@ import subprocess as sp
|
||||||
|
|
||||||
from . import config
|
from . import config
|
||||||
|
|
||||||
logger = logging.getLogger("pycalver2.vcs")
|
logger = logging.getLogger("bumpver.vcs")
|
||||||
|
|
||||||
|
|
||||||
VCS_SUBCOMMANDS_BY_NAME = {
|
VCS_SUBCOMMANDS_BY_NAME = {
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
[calver]
|
[bumpver]
|
||||||
current_version = "v2017.0123-alpha"
|
current_version = "v2017.0123-alpha"
|
||||||
version_pattern = "vYYYY.BUILD[-TAG]"
|
version_pattern = "vYYYY.BUILD[-TAG]"
|
||||||
commit = true
|
commit = true
|
||||||
tag = true
|
tag = true
|
||||||
push = true
|
push = true
|
||||||
|
|
||||||
[calver.file_patterns]
|
[bumpver.file_patterns]
|
||||||
"calver.toml" = [
|
"bumpver.toml" = [
|
||||||
'current_version = "{version}"',
|
'current_version = "{version}"',
|
||||||
]
|
]
|
||||||
|
|
||||||
4
test/fixtures/project_b/setup.cfg
vendored
4
test/fixtures/project_b/setup.cfg
vendored
|
|
@ -1,11 +1,11 @@
|
||||||
[calver]
|
[bumpver]
|
||||||
current_version = v201307.0456-beta
|
current_version = v201307.0456-beta
|
||||||
version_pattern = {pycalver}
|
version_pattern = {pycalver}
|
||||||
commit = True
|
commit = True
|
||||||
tag = True
|
tag = True
|
||||||
push = True
|
push = True
|
||||||
|
|
||||||
[calver:file_patterns]
|
[bumpver:file_patterns]
|
||||||
setup.cfg =
|
setup.cfg =
|
||||||
current_version = {version}
|
current_version = {version}
|
||||||
setup.py =
|
setup.py =
|
||||||
|
|
|
||||||
2
test/fixtures/project_c/pyproject.toml
vendored
2
test/fixtures/project_c/pyproject.toml
vendored
|
|
@ -1,4 +1,4 @@
|
||||||
[calver]
|
[bumpver]
|
||||||
current_version = "v2017q1.54321"
|
current_version = "v2017q1.54321"
|
||||||
version_pattern = "v{year}q{quarter}.{build_no}"
|
version_pattern = "v{year}q{quarter}.{build_no}"
|
||||||
commit = true
|
commit = true
|
||||||
|
|
|
||||||
126
test/test_cli.py
126
test/test_cli.py
|
|
@ -17,9 +17,9 @@ import pytest
|
||||||
import pathlib2 as pl
|
import pathlib2 as pl
|
||||||
from click.testing import CliRunner
|
from click.testing import CliRunner
|
||||||
|
|
||||||
from pycalver2 import cli
|
from bumpver import cli
|
||||||
from pycalver2 import config
|
from bumpver import config
|
||||||
from pycalver2 import v2patterns
|
from bumpver import v2patterns
|
||||||
|
|
||||||
# pylint:disable=redefined-outer-name ; pytest fixtures
|
# pylint:disable=redefined-outer-name ; pytest fixtures
|
||||||
# pylint:disable=protected-access ; allowed for test code
|
# pylint:disable=protected-access ; allowed for test code
|
||||||
|
|
@ -51,11 +51,11 @@ requires = ["setuptools", "wheel"]
|
||||||
"""
|
"""
|
||||||
|
|
||||||
ENV = {
|
ENV = {
|
||||||
'GIT_AUTHOR_NAME' : "calver_tester",
|
'GIT_AUTHOR_NAME' : "bumpver_tester",
|
||||||
'GIT_COMMITTER_NAME' : "calver_tester",
|
'GIT_COMMITTER_NAME' : "bumpver_tester",
|
||||||
'GIT_AUTHOR_EMAIL' : "calver_tester@nowhere.com",
|
'GIT_AUTHOR_EMAIL' : "bumpver_tester@nowhere.com",
|
||||||
'GIT_COMMITTER_EMAIL': "calver_tester@nowhere.com",
|
'GIT_COMMITTER_EMAIL': "bumpver_tester@nowhere.com",
|
||||||
'HGUSER' : "calver_tester",
|
'HGUSER' : "bumpver_tester",
|
||||||
'PATH' : os.environ['PATH'],
|
'PATH' : os.environ['PATH'],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -81,7 +81,7 @@ def runner(tmpdir):
|
||||||
|
|
||||||
_debug = 0
|
_debug = 0
|
||||||
if _debug:
|
if _debug:
|
||||||
tmpdir = pl.Path("..") / "tmp_test_pycalver_project"
|
tmpdir = pl.Path("..") / "tmp_test_bumpver_project"
|
||||||
if tmpdir.exists():
|
if tmpdir.exists():
|
||||||
time.sleep(0.2)
|
time.sleep(0.2)
|
||||||
shutil.rmtree(str(tmpdir))
|
shutil.rmtree(str(tmpdir))
|
||||||
|
|
@ -101,7 +101,7 @@ def test_help(runner):
|
||||||
result = runner.invoke(cli.cli, ['--help', "-vv"])
|
result = runner.invoke(cli.cli, ['--help', "-vv"])
|
||||||
assert result.exit_code == 0
|
assert result.exit_code == 0
|
||||||
assert "CalVer" in result.output
|
assert "CalVer" in result.output
|
||||||
assert "bump " in result.output
|
assert "update " in result.output
|
||||||
assert "test " in result.output
|
assert "test " in result.output
|
||||||
assert "init " in result.output
|
assert "init " in result.output
|
||||||
assert "show " in result.output
|
assert "show " in result.output
|
||||||
|
|
@ -110,8 +110,8 @@ def test_help(runner):
|
||||||
def test_version(runner):
|
def test_version(runner):
|
||||||
result = runner.invoke(cli.cli, ['--version', "-vv"])
|
result = runner.invoke(cli.cli, ['--version', "-vv"])
|
||||||
assert result.exit_code == 0
|
assert result.exit_code == 0
|
||||||
assert " version v20" in result.output
|
assert " version 20" in result.output
|
||||||
pattern = v2patterns.compile_pattern("vYYYY.BUILD[-TAG]")
|
pattern = v2patterns.compile_pattern("YYYY.BUILD[-TAG]")
|
||||||
match = pattern.regexp.search(result.output)
|
match = pattern.regexp.search(result.output)
|
||||||
assert match
|
assert match
|
||||||
|
|
||||||
|
|
@ -188,23 +188,21 @@ def test_incr_semver_invalid(runner, caplog):
|
||||||
def test_incr_to_beta(runner):
|
def test_incr_to_beta(runner):
|
||||||
pattern = "vYYYY.BUILD[-TAG]"
|
pattern = "vYYYY.BUILD[-TAG]"
|
||||||
old_version = "v2017.1999-alpha"
|
old_version = "v2017.1999-alpha"
|
||||||
initial_version = config._initial_version()
|
new_version = dt.datetime.utcnow().strftime("v%Y.22000-beta")
|
||||||
|
|
||||||
result = runner.invoke(cli.cli, ['test', "-vv", old_version, pattern, "--tag", "beta"])
|
result = runner.invoke(cli.cli, ['test', "-vv", old_version, pattern, "--tag", "beta"])
|
||||||
assert result.exit_code == 0
|
assert result.exit_code == 0
|
||||||
new_version = initial_version.replace(".1001-alpha", ".22000-beta")
|
|
||||||
assert f"Version: {new_version}\n" in result.output
|
assert f"Version: {new_version}\n" in result.output
|
||||||
|
|
||||||
|
|
||||||
def test_incr_to_final(runner, caplog):
|
def test_incr_to_final(runner, caplog):
|
||||||
pattern = "vYYYY.BUILD[-TAG]"
|
pattern = "vYYYY.BUILD[-TAG]"
|
||||||
old_version = "v2017.1999-alpha"
|
old_version = "v2017.1999-alpha"
|
||||||
initial_version = config._initial_version()
|
new_version = dt.datetime.utcnow().strftime("v%Y.22000")
|
||||||
|
|
||||||
result = runner.invoke(cli.cli, ['test', "-vv", old_version, pattern, "--tag", "final"])
|
result = runner.invoke(cli.cli, ['test', "-vv", old_version, pattern, "--tag", "final"])
|
||||||
_debug_records(caplog)
|
_debug_records(caplog)
|
||||||
assert result.exit_code == 0
|
assert result.exit_code == 0
|
||||||
new_version = initial_version.replace(".1001-alpha", ".22000")
|
|
||||||
assert f"Version: {new_version}\n" in result.output
|
assert f"Version: {new_version}\n" in result.output
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -252,14 +250,14 @@ def _add_project_files(*files):
|
||||||
with pl.Path("pycalver.toml").open(mode="wt", encoding="utf-8") as fobj:
|
with pl.Path("pycalver.toml").open(mode="wt", encoding="utf-8") as fobj:
|
||||||
fobj.write(CALVER_TOML_FIXTURE)
|
fobj.write(CALVER_TOML_FIXTURE)
|
||||||
|
|
||||||
if "calver.toml" in files:
|
|
||||||
with pl.Path("calver.toml").open(mode="wt", encoding="utf-8") as fobj:
|
|
||||||
fobj.write(CALVER_TOML_FIXTURE)
|
|
||||||
|
|
||||||
if "pyproject.toml" in files:
|
if "pyproject.toml" in files:
|
||||||
with pl.Path("pyproject.toml").open(mode="wt", encoding="utf-8") as fobj:
|
with pl.Path("pyproject.toml").open(mode="wt", encoding="utf-8") as fobj:
|
||||||
fobj.write(PYPROJECT_TOML_FIXTURE)
|
fobj.write(PYPROJECT_TOML_FIXTURE)
|
||||||
|
|
||||||
|
if "bumpver.toml" in files:
|
||||||
|
with pl.Path("bumpver.toml").open(mode="wt", encoding="utf-8") as fobj:
|
||||||
|
fobj.write(CALVER_TOML_FIXTURE)
|
||||||
|
|
||||||
|
|
||||||
def _update_config_val(filename, **kwargs):
|
def _update_config_val(filename, **kwargs):
|
||||||
with io.open(filename, mode="r", encoding="utf-8") as fobj:
|
with io.open(filename, mode="r", encoding="utf-8") as fobj:
|
||||||
|
|
@ -281,7 +279,8 @@ def test_nocfg(runner, caplog):
|
||||||
_add_project_files("README.md")
|
_add_project_files("README.md")
|
||||||
result = runner.invoke(cli.cli, ['show', "-vv"])
|
result = runner.invoke(cli.cli, ['show', "-vv"])
|
||||||
assert result.exit_code == 1
|
assert result.exit_code == 1
|
||||||
expected_msg = "Could not parse configuration. Perhaps try 'calver init'."
|
expected_msg = "Could not parse configuration. Perhaps try 'bumpver init'."
|
||||||
|
_debug_records(caplog)
|
||||||
assert any(expected_msg in r.message for r in caplog.records)
|
assert any(expected_msg in r.message for r in caplog.records)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -290,14 +289,14 @@ def test_novcs_nocfg_init(runner, caplog):
|
||||||
# dry mode test
|
# dry mode test
|
||||||
result = runner.invoke(cli.cli, ['init', "-vv", "--dry"])
|
result = runner.invoke(cli.cli, ['init', "-vv", "--dry"])
|
||||||
assert result.exit_code == 0
|
assert result.exit_code == 0
|
||||||
assert not os.path.exists("calver.toml")
|
assert not os.path.exists("bumpver.toml")
|
||||||
|
|
||||||
# non dry mode
|
# non dry mode
|
||||||
result = runner.invoke(cli.cli, ['init', "-vv"])
|
result = runner.invoke(cli.cli, ['init', "-vv"])
|
||||||
assert result.exit_code == 0
|
assert result.exit_code == 0
|
||||||
|
|
||||||
assert os.path.exists("calver.toml")
|
assert os.path.exists("bumpver.toml")
|
||||||
with pl.Path("calver.toml").open(mode="r", encoding="utf-8") as fobj:
|
with pl.Path("bumpver.toml").open(mode="r", encoding="utf-8") as fobj:
|
||||||
cfg_content = fobj.read()
|
cfg_content = fobj.read()
|
||||||
|
|
||||||
base_str = config.DEFAULT_TOML_BASE_TMPL.format(initial_version=config._initial_version())
|
base_str = config.DEFAULT_TOML_BASE_TMPL.format(initial_version=config._initial_version())
|
||||||
|
|
@ -305,6 +304,7 @@ def test_novcs_nocfg_init(runner, caplog):
|
||||||
assert config.DEFAULT_TOML_README_MD_STR in cfg_content
|
assert config.DEFAULT_TOML_README_MD_STR in cfg_content
|
||||||
|
|
||||||
result = runner.invoke(cli.cli, ['show', "-vv"])
|
result = runner.invoke(cli.cli, ['show', "-vv"])
|
||||||
|
_debug_records(caplog)
|
||||||
assert result.exit_code == 0
|
assert result.exit_code == 0
|
||||||
assert f"Current Version: {config._initial_version()}\n" in result.output
|
assert f"Current Version: {config._initial_version()}\n" in result.output
|
||||||
assert f"PEP440 : {config._initial_version_pep440()}\n" in result.output
|
assert f"PEP440 : {config._initial_version_pep440()}\n" in result.output
|
||||||
|
|
@ -390,7 +390,7 @@ def test_git_init(runner, version_pattern, cur_version, cur_pep440):
|
||||||
assert result.exit_code == 0
|
assert result.exit_code == 0
|
||||||
|
|
||||||
_update_config_val(
|
_update_config_val(
|
||||||
"calver.toml",
|
"bumpver.toml",
|
||||||
version_pattern=version_pattern,
|
version_pattern=version_pattern,
|
||||||
current_version='"' + cur_version + '"',
|
current_version='"' + cur_version + '"',
|
||||||
)
|
)
|
||||||
|
|
@ -409,7 +409,7 @@ def test_hg_init(runner, version_pattern, cur_version, cur_pep440):
|
||||||
assert result.exit_code == 0
|
assert result.exit_code == 0
|
||||||
|
|
||||||
_update_config_val(
|
_update_config_val(
|
||||||
"calver.toml",
|
"bumpver.toml",
|
||||||
version_pattern=version_pattern,
|
version_pattern=version_pattern,
|
||||||
current_version='"' + cur_version + '"',
|
current_version='"' + cur_version + '"',
|
||||||
)
|
)
|
||||||
|
|
@ -430,7 +430,7 @@ def test_v1_git_tag_eval(runner, version_pattern, cur_version, cur_pep440):
|
||||||
assert result.exit_code == 0
|
assert result.exit_code == 0
|
||||||
|
|
||||||
_update_config_val(
|
_update_config_val(
|
||||||
"calver.toml",
|
"bumpver.toml",
|
||||||
version_pattern=version_pattern,
|
version_pattern=version_pattern,
|
||||||
current_version='"' + cur_version + '"',
|
current_version='"' + cur_version + '"',
|
||||||
)
|
)
|
||||||
|
|
@ -456,7 +456,7 @@ def test_hg_tag_eval(runner, version_pattern, cur_version, cur_pep440):
|
||||||
assert result.exit_code == 0
|
assert result.exit_code == 0
|
||||||
|
|
||||||
_update_config_val(
|
_update_config_val(
|
||||||
"calver.toml",
|
"bumpver.toml",
|
||||||
version_pattern=version_pattern,
|
version_pattern=version_pattern,
|
||||||
current_version='"' + cur_version + '"',
|
current_version='"' + cur_version + '"',
|
||||||
)
|
)
|
||||||
|
|
@ -480,7 +480,7 @@ def test_novcs_bump(runner, version_pattern, cur_version, cur_pep440):
|
||||||
assert result.exit_code == 0
|
assert result.exit_code == 0
|
||||||
|
|
||||||
_update_config_val(
|
_update_config_val(
|
||||||
"calver.toml",
|
"bumpver.toml",
|
||||||
version_pattern=version_pattern,
|
version_pattern=version_pattern,
|
||||||
current_version='"' + cur_version + '"',
|
current_version='"' + cur_version + '"',
|
||||||
)
|
)
|
||||||
|
|
@ -488,7 +488,7 @@ def test_novcs_bump(runner, version_pattern, cur_version, cur_pep440):
|
||||||
with pl.Path("README.md").open(mode="r") as fobj:
|
with pl.Path("README.md").open(mode="r") as fobj:
|
||||||
content = fobj.read()
|
content = fobj.read()
|
||||||
|
|
||||||
result = runner.invoke(cli.cli, ['bump', "-vv"])
|
result = runner.invoke(cli.cli, ['update', "-vv"])
|
||||||
assert result.exit_code == 0
|
assert result.exit_code == 0
|
||||||
|
|
||||||
calver = cur_version.split(".")[0]
|
calver = cur_version.split(".")[0]
|
||||||
|
|
@ -498,7 +498,7 @@ def test_novcs_bump(runner, version_pattern, cur_version, cur_pep440):
|
||||||
assert calver + ".1002-alpha !\n" in content
|
assert calver + ".1002-alpha !\n" in content
|
||||||
assert calver[1:] + ".1002a0 !]\n" in content
|
assert calver[1:] + ".1002a0 !]\n" in content
|
||||||
|
|
||||||
result = runner.invoke(cli.cli, ['bump', "-vv", "--tag", "beta"])
|
result = runner.invoke(cli.cli, ['update', "-vv", "--tag", "beta"])
|
||||||
assert result.exit_code == 0
|
assert result.exit_code == 0
|
||||||
|
|
||||||
with pl.Path("README.md").open() as fobj:
|
with pl.Path("README.md").open() as fobj:
|
||||||
|
|
@ -516,15 +516,15 @@ def test_git_bump(runner, caplog, version_pattern, cur_version, cur_pep440):
|
||||||
assert result.exit_code == 0
|
assert result.exit_code == 0
|
||||||
|
|
||||||
_update_config_val(
|
_update_config_val(
|
||||||
"calver.toml",
|
"bumpver.toml",
|
||||||
version_pattern=version_pattern,
|
version_pattern=version_pattern,
|
||||||
current_version='"' + cur_version + '"',
|
current_version='"' + cur_version + '"',
|
||||||
)
|
)
|
||||||
|
|
||||||
shell("git", "add", "calver.toml")
|
shell("git", "add", "bumpver.toml")
|
||||||
shell("git", "commit", "-m", "initial commit")
|
shell("git", "commit", "-m", "initial commit")
|
||||||
|
|
||||||
result = runner.invoke(cli.cli, ['bump', "-vv"])
|
result = runner.invoke(cli.cli, ['update', "-vv"])
|
||||||
_debug_records(caplog)
|
_debug_records(caplog)
|
||||||
assert result.exit_code == 0
|
assert result.exit_code == 0
|
||||||
|
|
||||||
|
|
@ -544,15 +544,15 @@ def test_hg_bump(runner, version_pattern, cur_version, cur_pep440):
|
||||||
assert result.exit_code == 0
|
assert result.exit_code == 0
|
||||||
|
|
||||||
_update_config_val(
|
_update_config_val(
|
||||||
"calver.toml",
|
"bumpver.toml",
|
||||||
version_pattern=version_pattern,
|
version_pattern=version_pattern,
|
||||||
current_version='"' + cur_version + '"',
|
current_version='"' + cur_version + '"',
|
||||||
)
|
)
|
||||||
|
|
||||||
shell("hg", "add", "calver.toml")
|
shell("hg", "add", "bumpver.toml")
|
||||||
shell("hg", "commit", "-m", "initial commit")
|
shell("hg", "commit", "-m", "initial commit")
|
||||||
|
|
||||||
result = runner.invoke(cli.cli, ['bump', "-vv"])
|
result = runner.invoke(cli.cli, ['update', "-vv"])
|
||||||
assert result.exit_code == 0
|
assert result.exit_code == 0
|
||||||
|
|
||||||
calver = cur_version.split(".")[0]
|
calver = cur_version.split(".")[0]
|
||||||
|
|
@ -573,12 +573,12 @@ def test_empty_git_bump(runner, caplog):
|
||||||
with pl.Path("setup.cfg").open(mode="r") as fobj:
|
with pl.Path("setup.cfg").open(mode="r") as fobj:
|
||||||
default_cfg_data = fobj.read()
|
default_cfg_data = fobj.read()
|
||||||
|
|
||||||
assert "[calver]\n" in default_cfg_data
|
assert "[bumpver]\n" in default_cfg_data
|
||||||
assert "\ncurrent_version = " in default_cfg_data
|
assert "\ncurrent_version = " in default_cfg_data
|
||||||
assert "\n[calver:file_patterns]\n" in default_cfg_data
|
assert "\n[bumpver:file_patterns]\n" in default_cfg_data
|
||||||
assert "\nsetup.cfg =\n" in default_cfg_data
|
assert "\nsetup.cfg =\n" in default_cfg_data
|
||||||
|
|
||||||
result = runner.invoke(cli.cli, ['bump'])
|
result = runner.invoke(cli.cli, ['update'])
|
||||||
|
|
||||||
assert any(("working directory is not clean" in r.message) for r in caplog.records)
|
assert any(("working directory is not clean" in r.message) for r in caplog.records)
|
||||||
assert any(("setup.cfg" in r.message) for r in caplog.records)
|
assert any(("setup.cfg" in r.message) for r in caplog.records)
|
||||||
|
|
@ -595,12 +595,12 @@ def test_empty_hg_bump(runner, caplog):
|
||||||
with pl.Path("setup.cfg").open(mode="r") as fobj:
|
with pl.Path("setup.cfg").open(mode="r") as fobj:
|
||||||
default_cfg_text = fobj.read()
|
default_cfg_text = fobj.read()
|
||||||
|
|
||||||
assert "[calver]\n" in default_cfg_text
|
assert "[bumpver]\n" in default_cfg_text
|
||||||
assert "\ncurrent_version = " in default_cfg_text
|
assert "\ncurrent_version = " in default_cfg_text
|
||||||
assert "\n[calver:file_patterns]\n" in default_cfg_text
|
assert "\n[bumpver:file_patterns]\n" in default_cfg_text
|
||||||
assert "\nsetup.cfg =\n" in default_cfg_text
|
assert "\nsetup.cfg =\n" in default_cfg_text
|
||||||
|
|
||||||
result = runner.invoke(cli.cli, ['bump'])
|
result = runner.invoke(cli.cli, ['update'])
|
||||||
|
|
||||||
assert any(("working directory is not clean" in r.message) for r in caplog.records)
|
assert any(("working directory is not clean" in r.message) for r in caplog.records)
|
||||||
assert any(("setup.cfg" in r.message) for r in caplog.records)
|
assert any(("setup.cfg" in r.message) for r in caplog.records)
|
||||||
|
|
@ -640,13 +640,13 @@ def test_v1_bump_semver_warning(runner, caplog, version_pattern):
|
||||||
|
|
||||||
_vcs_init("hg", files=["README.md", "setup.cfg"])
|
_vcs_init("hg", files=["README.md", "setup.cfg"])
|
||||||
|
|
||||||
result = runner.invoke(cli.cli, ['bump', "-vv", "-n", "--dry"])
|
result = runner.invoke(cli.cli, ['update', "-vv", "-n", "--dry"])
|
||||||
assert result.exit_code == 1
|
assert result.exit_code == 1
|
||||||
|
|
||||||
assert any("version did not change" in r.message for r in caplog.records)
|
assert any("version did not change" in r.message for r in caplog.records)
|
||||||
assert any("[--major/--minor/--patch] required" in r.message for r in caplog.records)
|
assert any("[--major/--minor/--patch] required" in r.message for r in caplog.records)
|
||||||
|
|
||||||
result = runner.invoke(cli.cli, ['bump', "-vv", "-n", "--dry", "--patch"])
|
result = runner.invoke(cli.cli, ['update', "-vv", "-n", "--dry", "--patch"])
|
||||||
assert result.exit_code == 0
|
assert result.exit_code == 0
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -664,7 +664,7 @@ def test_v1_bump_semver_diff(runner, caplog, version_pattern):
|
||||||
cases = [("--major", "1.0.0"), ("--minor", "0.2.0"), ("--patch", "0.1.1")]
|
cases = [("--major", "1.0.0"), ("--minor", "0.2.0"), ("--patch", "0.1.1")]
|
||||||
|
|
||||||
for flag, expected in cases:
|
for flag, expected in cases:
|
||||||
result = runner.invoke(cli.cli, ['bump', "-vv", "-n", "--dry", flag])
|
result = runner.invoke(cli.cli, ['update', "-vv", "-n", "--dry", flag])
|
||||||
assert result.exit_code == 0
|
assert result.exit_code == 0
|
||||||
assert len(caplog.records) == 0
|
assert len(caplog.records) == 0
|
||||||
|
|
||||||
|
|
@ -769,13 +769,17 @@ def test_hg_commit_message(runner, caplog):
|
||||||
commit_message = """
|
commit_message = """
|
||||||
"bump from {old_version} ({old_version_pep440}) to {new_version} ({new_version_pep440})"
|
"bump from {old_version} ({old_version_pep440}) to {new_version} ({new_version_pep440})"
|
||||||
"""
|
"""
|
||||||
_update_config_val("setup.cfg", current_version='"v2019.1001-alpha"')
|
_update_config_val(
|
||||||
_update_config_val("setup.cfg", commit_message=commit_message.strip())
|
"setup.cfg",
|
||||||
|
current_version='"v2019.1001-alpha"',
|
||||||
|
version_pattern="vYYYY.BUILD[-TAG]",
|
||||||
|
commit_message=commit_message.strip(),
|
||||||
|
)
|
||||||
|
|
||||||
_vcs_init("hg", ["README.md", "setup.cfg"])
|
_vcs_init("hg", ["README.md", "setup.cfg"])
|
||||||
assert len(caplog.records) > 0
|
assert len(caplog.records) > 0
|
||||||
|
|
||||||
result = runner.invoke(cli.cli, ['bump', "-vv", "--pin-date", "--tag", "beta"])
|
result = runner.invoke(cli.cli, ['update', "-vv", "--pin-date", "--tag", "beta"])
|
||||||
assert result.exit_code == 0
|
assert result.exit_code == 0
|
||||||
|
|
||||||
tags = shell("hg", "tags").decode("utf-8")
|
tags = shell("hg", "tags").decode("utf-8")
|
||||||
|
|
@ -796,13 +800,17 @@ def test_git_commit_message(runner, caplog):
|
||||||
commit_message = """
|
commit_message = """
|
||||||
"bump: {old_version} ({old_version_pep440}) -> {new_version} ({new_version_pep440})"
|
"bump: {old_version} ({old_version_pep440}) -> {new_version} ({new_version_pep440})"
|
||||||
"""
|
"""
|
||||||
_update_config_val("setup.cfg", current_version='"v2019.1001-alpha"')
|
_update_config_val(
|
||||||
_update_config_val("setup.cfg", commit_message=commit_message.strip())
|
"setup.cfg",
|
||||||
|
current_version='"v2019.1001-alpha"',
|
||||||
|
version_pattern="vYYYY.BUILD[-TAG]",
|
||||||
|
commit_message=commit_message.strip(),
|
||||||
|
)
|
||||||
|
|
||||||
_vcs_init("git", ["README.md", "setup.cfg"])
|
_vcs_init("git", ["README.md", "setup.cfg"])
|
||||||
assert len(caplog.records) > 0
|
assert len(caplog.records) > 0
|
||||||
|
|
||||||
result = runner.invoke(cli.cli, ['bump', "-vv", "--pin-date", "--tag", "beta"])
|
result = runner.invoke(cli.cli, ['update', "-vv", "--pin-date", "--tag", "beta"])
|
||||||
assert result.exit_code == 0
|
assert result.exit_code == 0
|
||||||
|
|
||||||
tags = shell("git", "tag", "--list").decode("utf-8")
|
tags = shell("git", "tag", "--list").decode("utf-8")
|
||||||
|
|
@ -870,7 +878,7 @@ def test_multimatch_file_patterns(runner):
|
||||||
with pl.Path("setup.cfg").open(mode="w", encoding="utf-8") as fobj:
|
with pl.Path("setup.cfg").open(mode="w", encoding="utf-8") as fobj:
|
||||||
fobj.write(SETUP_CFG_MULTIMATCH_FILE_PATTERNS_FIXTURE)
|
fobj.write(SETUP_CFG_MULTIMATCH_FILE_PATTERNS_FIXTURE)
|
||||||
|
|
||||||
result = runner.invoke(cli.cli, ['bump', '--tag', 'beta', '--date', "2020-11-22"])
|
result = runner.invoke(cli.cli, ['update', '--tag', 'beta', '--date', "2020-11-22"])
|
||||||
assert result.exit_code == 0
|
assert result.exit_code == 0
|
||||||
|
|
||||||
with pl.Path("README.md").open(mode="r", encoding="utf-8") as fobj:
|
with pl.Path("README.md").open(mode="r", encoding="utf-8") as fobj:
|
||||||
|
|
@ -921,20 +929,20 @@ def test_get_latest_vcs_version_tag(runner):
|
||||||
result = runner.invoke(cli.cli, ['init', "-vv"])
|
result = runner.invoke(cli.cli, ['init', "-vv"])
|
||||||
assert result.exit_code == 0
|
assert result.exit_code == 0
|
||||||
|
|
||||||
_update_config_val("calver.toml", push="false")
|
_update_config_val("bumpver.toml", push="false")
|
||||||
_update_config_val("calver.toml", current_version='"0.1.8"')
|
_update_config_val("bumpver.toml", current_version='"0.1.8"')
|
||||||
_update_config_val("calver.toml", version_pattern='"MAJOR.MINOR.PATCH"')
|
_update_config_val("bumpver.toml", version_pattern='"MAJOR.MINOR.PATCH"')
|
||||||
|
|
||||||
_vcs_init("git", files=["calver.toml"])
|
_vcs_init("git", files=["bumpver.toml"])
|
||||||
|
|
||||||
result = runner.invoke(cli.cli, ['bump', "--patch"])
|
result = runner.invoke(cli.cli, ['update', "--patch"])
|
||||||
assert result.exit_code == 0
|
assert result.exit_code == 0
|
||||||
|
|
||||||
_, cfg = config.init()
|
_, cfg = config.init()
|
||||||
latest_version = cli.get_latest_vcs_version_tag(cfg, fetch=False)
|
latest_version = cli.get_latest_vcs_version_tag(cfg, fetch=False)
|
||||||
assert latest_version == "0.1.9"
|
assert latest_version == "0.1.9"
|
||||||
|
|
||||||
result = runner.invoke(cli.cli, ['bump', "--patch"])
|
result = runner.invoke(cli.cli, ['update', "--patch"])
|
||||||
assert result.exit_code == 0
|
assert result.exit_code == 0
|
||||||
|
|
||||||
_, cfg = config.init()
|
_, cfg = config.init()
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ from __future__ import unicode_literals
|
||||||
import io
|
import io
|
||||||
from test import util
|
from test import util
|
||||||
|
|
||||||
from pycalver2 import config
|
from bumpver import config
|
||||||
|
|
||||||
# pylint:disable=redefined-outer-name ; pytest fixtures
|
# pylint:disable=redefined-outer-name ; pytest fixtures
|
||||||
# pylint:disable=protected-access ; allowed for test code
|
# pylint:disable=protected-access ; allowed for test code
|
||||||
|
|
@ -51,33 +51,33 @@ push = false
|
||||||
"""
|
"""
|
||||||
|
|
||||||
CALVER_TOML_FIXTURE_3 = """
|
CALVER_TOML_FIXTURE_3 = """
|
||||||
[calver]
|
[bumpver]
|
||||||
current_version = "v201808.0123-alpha"
|
current_version = "v201808.0123-alpha"
|
||||||
version_pattern = "vYYYY0M.BUILD[-TAG]"
|
version_pattern = "vYYYY0M.BUILD[-TAG]"
|
||||||
commit = true
|
commit = true
|
||||||
tag = true
|
tag = true
|
||||||
push = true
|
push = true
|
||||||
|
|
||||||
[calver.file_patterns]
|
[bumpver.file_patterns]
|
||||||
"README.md" = [
|
"README.md" = [
|
||||||
"{version}",
|
"{version}",
|
||||||
"{pep440_version}",
|
"{pep440_version}",
|
||||||
]
|
]
|
||||||
"calver.toml" = [
|
"bumpver.toml" = [
|
||||||
'current_version = "{version}"',
|
'current_version = "{version}"',
|
||||||
]
|
]
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
SETUP_CFG_FIXTURE = """
|
SETUP_CFG_FIXTURE = """
|
||||||
[calver]
|
[bumpver]
|
||||||
current_version = "v201808.0456-beta"
|
current_version = "v201808.0456-beta"
|
||||||
version_pattern = "vYYYY0M.BUILD[-TAG]"
|
version_pattern = "vYYYY0M.BUILD[-TAG]"
|
||||||
commit = True
|
commit = True
|
||||||
tag = True
|
tag = True
|
||||||
push = True
|
push = True
|
||||||
|
|
||||||
[calver:file_patterns]
|
[bumpver:file_patterns]
|
||||||
setup.py =
|
setup.py =
|
||||||
{version}
|
{version}
|
||||||
{pep440_version}
|
{pep440_version}
|
||||||
|
|
@ -87,7 +87,7 @@ setup.cfg =
|
||||||
|
|
||||||
|
|
||||||
NEW_PATTERN_CFG_FIXTURE = """
|
NEW_PATTERN_CFG_FIXTURE = """
|
||||||
[calver]
|
[bumpver]
|
||||||
current_version = "v201808.1456-beta"
|
current_version = "v201808.1456-beta"
|
||||||
version_pattern = "vYYYY0M.BUILD[-TAG]"
|
version_pattern = "vYYYY0M.BUILD[-TAG]"
|
||||||
commit_message = "bump version to {new_version}"
|
commit_message = "bump version to {new_version}"
|
||||||
|
|
@ -95,7 +95,7 @@ commit = True
|
||||||
tag = True
|
tag = True
|
||||||
push = True
|
push = True
|
||||||
|
|
||||||
[calver:file_patterns]
|
[bumpver:file_patterns]
|
||||||
setup.py =
|
setup.py =
|
||||||
{version}
|
{version}
|
||||||
{pep440_version}
|
{pep440_version}
|
||||||
|
|
@ -172,11 +172,11 @@ def test_parse_toml_3():
|
||||||
assert cfg.push is True
|
assert cfg.push is True
|
||||||
|
|
||||||
files = set(cfg.file_patterns)
|
files = set(cfg.file_patterns)
|
||||||
assert "calver.toml" in files
|
assert "bumpver.toml" in files
|
||||||
|
|
||||||
raw_patterns_by_path = _parse_raw_patterns_by_filepath(cfg)
|
raw_patterns_by_path = _parse_raw_patterns_by_filepath(cfg)
|
||||||
assert raw_patterns_by_path["README.md" ] == ["vYYYY0M.BUILD[-TAG]", "YYYY0M.BLD[PYTAGNUM]"]
|
assert raw_patterns_by_path["README.md" ] == ["vYYYY0M.BUILD[-TAG]", "YYYY0M.BLD[PYTAGNUM]"]
|
||||||
assert raw_patterns_by_path["calver.toml"] == ['current_version = "vYYYY0M.BUILD[-TAG]"']
|
assert raw_patterns_by_path["bumpver.toml"] == ['current_version = "vYYYY0M.BUILD[-TAG]"']
|
||||||
|
|
||||||
|
|
||||||
def test_parse_v1_cfg():
|
def test_parse_v1_cfg():
|
||||||
|
|
@ -247,8 +247,8 @@ def test_parse_default_cfg():
|
||||||
|
|
||||||
def test_parse_project_toml():
|
def test_parse_project_toml():
|
||||||
project_path = util.FIXTURES_DIR / "project_a"
|
project_path = util.FIXTURES_DIR / "project_a"
|
||||||
config_path = util.FIXTURES_DIR / "project_a" / "calver.toml"
|
config_path = util.FIXTURES_DIR / "project_a" / "bumpver.toml"
|
||||||
config_rel_path = "calver.toml"
|
config_rel_path = "bumpver.toml"
|
||||||
|
|
||||||
with config_path.open() as fobj:
|
with config_path.open() as fobj:
|
||||||
config_data = fobj.read()
|
config_data = fobj.read()
|
||||||
|
|
@ -268,7 +268,7 @@ def test_parse_project_toml():
|
||||||
assert cfg.push is True
|
assert cfg.push is True
|
||||||
|
|
||||||
files = set(cfg.file_patterns.keys())
|
files = set(cfg.file_patterns.keys())
|
||||||
assert files == {"calver.toml", "README.md"}
|
assert files == {"bumpver.toml", "README.md"}
|
||||||
|
|
||||||
|
|
||||||
def test_parse_project_cfg():
|
def test_parse_project_cfg():
|
||||||
|
|
@ -406,7 +406,7 @@ def test_parse_missing_version(tmpdir):
|
||||||
setup_path.write(
|
setup_path.write(
|
||||||
"\n".join(
|
"\n".join(
|
||||||
(
|
(
|
||||||
"[calver]",
|
"[bumpver]",
|
||||||
# f"current_version = v201808.1001-dev",
|
# f"current_version = v201808.1001-dev",
|
||||||
"commit = False",
|
"commit = False",
|
||||||
)
|
)
|
||||||
|
|
@ -422,7 +422,7 @@ def test_parse_missing_version(tmpdir):
|
||||||
|
|
||||||
def test_parse_invalid_version(tmpdir):
|
def test_parse_invalid_version(tmpdir):
|
||||||
setup_path = tmpdir.mkdir("fail").join("setup.cfg")
|
setup_path = tmpdir.mkdir("fail").join("setup.cfg")
|
||||||
setup_path.write("\n".join(("[calver]", "current_version = 0.1.0", "commit = False")))
|
setup_path.write("\n".join(("[bumpver]", "current_version = 0.1.0", "commit = False")))
|
||||||
|
|
||||||
ctx = config.init_project_ctx(setup_path)
|
ctx = config.init_project_ctx(setup_path)
|
||||||
assert ctx
|
assert ctx
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,8 @@ from __future__ import print_function
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
from pycalver2 import parse
|
from bumpver import parse
|
||||||
from pycalver2 import v1patterns
|
from bumpver import v1patterns
|
||||||
|
|
||||||
SETUP_PY_FIXTURE = """
|
SETUP_PY_FIXTURE = """
|
||||||
# setup.py
|
# setup.py
|
||||||
|
|
|
||||||
|
|
@ -8,8 +8,8 @@ import re
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from pycalver2 import v1patterns
|
from bumpver import v1patterns
|
||||||
from pycalver2 import v2patterns
|
from bumpver import v2patterns
|
||||||
|
|
||||||
V2_PART_PATTERN_CASES = [
|
V2_PART_PATTERN_CASES = [
|
||||||
(['YYYY', 'GGGG'], "2020" , "2020"),
|
(['YYYY', 'GGGG'], "2020" , "2020"),
|
||||||
|
|
|
||||||
|
|
@ -8,14 +8,14 @@ import re
|
||||||
import copy
|
import copy
|
||||||
from test import util
|
from test import util
|
||||||
|
|
||||||
from pycalver2 import config
|
from bumpver import config
|
||||||
from pycalver2 import rewrite
|
from bumpver import rewrite
|
||||||
from pycalver2 import v1rewrite
|
from bumpver import v1rewrite
|
||||||
from pycalver2 import v1version
|
from bumpver import v1version
|
||||||
from pycalver2 import v2rewrite
|
from bumpver import v2rewrite
|
||||||
from pycalver2 import v2version
|
from bumpver import v2version
|
||||||
from pycalver2 import v1patterns
|
from bumpver import v1patterns
|
||||||
from pycalver2 import v2patterns
|
from bumpver import v2patterns
|
||||||
|
|
||||||
# pylint:disable=protected-access ; allowed for test code
|
# pylint:disable=protected-access ; allowed for test code
|
||||||
|
|
||||||
|
|
@ -102,7 +102,7 @@ def test_iter_file_paths():
|
||||||
_paths_and_patterns = rewrite.iter_path_patterns_items(cfg.file_patterns)
|
_paths_and_patterns = rewrite.iter_path_patterns_items(cfg.file_patterns)
|
||||||
file_paths = {str(file_path) for file_path, patterns in _paths_and_patterns}
|
file_paths = {str(file_path) for file_path, patterns in _paths_and_patterns}
|
||||||
|
|
||||||
assert file_paths == {"calver.toml", "README.md"}
|
assert file_paths == {"bumpver.toml", "README.md"}
|
||||||
|
|
||||||
|
|
||||||
def test_iter_file_globs():
|
def test_iter_file_globs():
|
||||||
|
|
@ -217,13 +217,13 @@ def test_v2_optional_release():
|
||||||
|
|
||||||
|
|
||||||
def test_v1_iter_rewritten():
|
def test_v1_iter_rewritten():
|
||||||
version_pattern = "v{year}{build}{release}"
|
version_pattern = "{year}{build}{release}"
|
||||||
new_vinfo = v1version.parse_version_info("v2018.0123", version_pattern)
|
new_vinfo = v1version.parse_version_info("2018.0123", version_pattern)
|
||||||
|
|
||||||
init_pattern = v1patterns.compile_pattern(
|
init_pattern = v1patterns.compile_pattern(
|
||||||
version_pattern, '__version__ = "v{year}{build}{release}"'
|
version_pattern, '__version__ = "{year}{build}{release}"'
|
||||||
)
|
)
|
||||||
file_patterns = {"src/pycalver2/__init__.py": [init_pattern]}
|
file_patterns = {"src/bumpver/__init__.py": [init_pattern]}
|
||||||
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 = [
|
||||||
|
|
@ -232,21 +232,21 @@ def test_v1_iter_rewritten():
|
||||||
"#",
|
"#",
|
||||||
"# 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",
|
||||||
'"""PyCalVer: CalVer for Python Packages."""',
|
'"""BumpVer: A CLI program for versioning."""',
|
||||||
'',
|
'',
|
||||||
'__version__ = "v2018.0123"',
|
'__version__ = "2018.0123"',
|
||||||
'',
|
'',
|
||||||
]
|
]
|
||||||
assert rfd.new_lines == expected
|
assert rfd.new_lines == expected
|
||||||
|
|
||||||
|
|
||||||
def test_v2_iter_rewritten():
|
def test_v2_iter_rewritten():
|
||||||
version_pattern = "vYYYY.BUILD[-TAG]"
|
version_pattern = "YYYY.BUILD[-TAG]"
|
||||||
new_vinfo = v2version.parse_version_info("v2018.0123", version_pattern)
|
new_vinfo = v2version.parse_version_info("2018.0123", version_pattern)
|
||||||
|
|
||||||
file_patterns = {
|
file_patterns = {
|
||||||
"src/pycalver2/__init__.py": [
|
"src/bumpver/__init__.py": [
|
||||||
v2patterns.compile_pattern(version_pattern, '__version__ = "vYYYY.BUILD[-TAG]"'),
|
v2patterns.compile_pattern(version_pattern, '__version__ = "YYYY.BUILD[-TAG]"'),
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -258,38 +258,41 @@ def test_v2_iter_rewritten():
|
||||||
"#",
|
"#",
|
||||||
"# 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",
|
||||||
'"""PyCalVer: CalVer for Python Packages."""',
|
'"""BumpVer: A CLI program for versioning."""',
|
||||||
'',
|
'',
|
||||||
'__version__ = "v2018.0123"',
|
'__version__ = "2018.0123"',
|
||||||
'',
|
'',
|
||||||
]
|
]
|
||||||
assert rfd.new_lines == expected
|
assert rfd.new_lines == expected
|
||||||
|
|
||||||
|
|
||||||
def test_v1_diff():
|
def test_v1_diff():
|
||||||
version_pattern = "v{year}{build}{release}"
|
version_pattern = "{year}{build}{release}"
|
||||||
raw_pattern = '__version__ = "v{year}{build}{release}"'
|
raw_pattern = '__version__ = "{year}{build}{release}"'
|
||||||
pattern = v1patterns.compile_pattern(version_pattern, raw_pattern)
|
pattern = v1patterns.compile_pattern(version_pattern, raw_pattern)
|
||||||
file_patterns = {"src/pycalver2/__init__.py": [pattern]}
|
file_patterns = {"src/bumpver/__init__.py": [pattern]}
|
||||||
|
|
||||||
old_vinfo = v1version.parse_version_info("v201809.0123")
|
old_vinfo = v1version.parse_version_info("v201809.0123")
|
||||||
new_vinfo = v1version.parse_version_info("v201911.1124")
|
new_vinfo = v1version.parse_version_info("v201911.1124")
|
||||||
assert new_vinfo > old_vinfo
|
assert new_vinfo > old_vinfo
|
||||||
|
|
||||||
old_vinfo = v1version.parse_version_info("v2018.0123", version_pattern)
|
old_vinfo = v1version.parse_version_info("2018.0123", version_pattern)
|
||||||
new_vinfo = v1version.parse_version_info("v2019.1124", version_pattern)
|
new_vinfo = v1version.parse_version_info("2019.1124", version_pattern)
|
||||||
|
|
||||||
diff_str = v1rewrite.diff(old_vinfo, new_vinfo, file_patterns)
|
diff_str = v1rewrite.diff(old_vinfo, new_vinfo, file_patterns)
|
||||||
lines = diff_str.split("\n")
|
lines = diff_str.split("\n")
|
||||||
|
|
||||||
assert lines[:2] == ["--- src/pycalver2/__init__.py", "+++ src/pycalver2/__init__.py"]
|
assert lines[:2] == [
|
||||||
|
"--- src/bumpver/__init__.py",
|
||||||
|
"+++ src/bumpver/__init__.py",
|
||||||
|
]
|
||||||
|
|
||||||
assert lines[6].startswith('-__version__ = "v20')
|
assert lines[6].startswith('-__version__ = "20')
|
||||||
assert lines[7].startswith('+__version__ = "v20')
|
assert lines[7].startswith('+__version__ = "20')
|
||||||
|
|
||||||
assert not lines[6].startswith('-__version__ = "v2018.0123"')
|
assert not lines[6].startswith('-__version__ = "2018.0123"')
|
||||||
|
|
||||||
assert lines[7] == '+__version__ = "v2019.1124"'
|
assert lines[7] == '+__version__ = "2019.1124"'
|
||||||
|
|
||||||
raw_pattern = "Copyright (c) 2018-{year}"
|
raw_pattern = "Copyright (c) 2018-{year}"
|
||||||
pattern = v1patterns.compile_pattern(version_pattern, raw_pattern)
|
pattern = v1patterns.compile_pattern(version_pattern, raw_pattern)
|
||||||
|
|
@ -302,25 +305,28 @@ def test_v1_diff():
|
||||||
|
|
||||||
|
|
||||||
def test_v2_diff():
|
def test_v2_diff():
|
||||||
version_pattern = "vYYYY.BUILD[-TAG]"
|
version_pattern = "YYYY.BUILD[-TAG]"
|
||||||
raw_pattern = '__version__ = "vYYYY.BUILD[-TAG]"'
|
raw_pattern = '__version__ = "YYYY.BUILD[-TAG]"'
|
||||||
pattern = v2patterns.compile_pattern(version_pattern, raw_pattern)
|
pattern = v2patterns.compile_pattern(version_pattern, raw_pattern)
|
||||||
file_patterns = {"src/pycalver2/__init__.py": [pattern]}
|
file_patterns = {"src/bumpver/__init__.py": [pattern]}
|
||||||
|
|
||||||
old_vinfo = v2version.parse_version_info("v2018.0123", version_pattern)
|
old_vinfo = v2version.parse_version_info("2018.0123", version_pattern)
|
||||||
new_vinfo = v2version.parse_version_info("v2019.1124", version_pattern)
|
new_vinfo = v2version.parse_version_info("2019.1124", version_pattern)
|
||||||
|
|
||||||
diff_str = v2rewrite.diff(old_vinfo, new_vinfo, file_patterns)
|
diff_str = v2rewrite.diff(old_vinfo, new_vinfo, file_patterns)
|
||||||
lines = diff_str.split("\n")
|
lines = diff_str.split("\n")
|
||||||
|
|
||||||
assert lines[:2] == ["--- src/pycalver2/__init__.py", "+++ src/pycalver2/__init__.py"]
|
assert lines[:2] == [
|
||||||
|
"--- src/bumpver/__init__.py",
|
||||||
|
"+++ src/bumpver/__init__.py",
|
||||||
|
]
|
||||||
|
|
||||||
assert lines[6].startswith('-__version__ = "v20')
|
assert lines[6].startswith('-__version__ = "20')
|
||||||
assert lines[7].startswith('+__version__ = "v20')
|
assert lines[7].startswith('+__version__ = "20')
|
||||||
|
|
||||||
assert not lines[6].startswith('-__version__ = "v2018.0123"')
|
assert not lines[6].startswith('-__version__ = "2018.0123"')
|
||||||
|
|
||||||
assert lines[7] == '+__version__ = "v2019.1124"'
|
assert lines[7] == '+__version__ = "2019.1124"'
|
||||||
|
|
||||||
raw_pattern = "Copyright (c) 2018-YYYY"
|
raw_pattern = "Copyright (c) 2018-YYYY"
|
||||||
pattern = v2patterns.compile_pattern(version_pattern, raw_pattern)
|
pattern = v2patterns.compile_pattern(version_pattern, raw_pattern)
|
||||||
|
|
|
||||||
|
|
@ -9,11 +9,11 @@ import datetime as dt
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from pycalver2 import version
|
from bumpver import version
|
||||||
from pycalver2 import v1version
|
from bumpver import v1version
|
||||||
from pycalver2 import v2version
|
from bumpver import v2version
|
||||||
from pycalver2 import v1patterns
|
from bumpver import v1patterns
|
||||||
from pycalver2 import v2patterns
|
from bumpver import v2patterns
|
||||||
|
|
||||||
# pylint:disable=protected-access ; allowed for test code
|
# pylint:disable=protected-access ; allowed for test code
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ FIXTURE_PATH_PARTS = [
|
||||||
["setup.cfg"],
|
["setup.cfg"],
|
||||||
["setup.py"],
|
["setup.py"],
|
||||||
["pycalver.toml"],
|
["pycalver.toml"],
|
||||||
["calver.toml"],
|
["bumpver.toml"],
|
||||||
["src", "module_v1", "__init__.py"],
|
["src", "module_v1", "__init__.py"],
|
||||||
["src", "module_v2", "__init__.py"],
|
["src", "module_v2", "__init__.py"],
|
||||||
]
|
]
|
||||||
|
|
@ -41,7 +41,7 @@ class Project:
|
||||||
self.tmpdir = tmpdir
|
self.tmpdir = tmpdir
|
||||||
self.prev_cwd = os.getcwd()
|
self.prev_cwd = os.getcwd()
|
||||||
|
|
||||||
self.dir = tmpdir / "pycalver_project"
|
self.dir = tmpdir / "bumpver_project"
|
||||||
self.dir.mkdir()
|
self.dir.mkdir()
|
||||||
|
|
||||||
if project is None:
|
if project is None:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue