Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

check for tag if tag-num specified #153

Merged
merged 2 commits into from
Jan 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -216,4 +216,7 @@ fabric.properties
.idea/httpRequests

# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser
.idea/caches/build_file_checksums.ser

# Visual Studio Code
.vscode
5 changes: 5 additions & 0 deletions src/bumpver/v2version.py
Original file line number Diff line number Diff line change
Expand Up @@ -754,6 +754,11 @@ def incr(
else:
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(
raw_pattern,
old_vinfo,
Expand Down
12 changes: 12 additions & 0 deletions test/test_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,18 @@ def test_bump_random(monkeypatch):
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():
version_str = "v201712.0001-alpha"
version_info = v1version.parse_version_info(version_str)
Expand Down