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

should not allow tag-num if there is no tag #151

Closed
dwapstra opened this issue Jan 17, 2021 · 5 comments
Closed

should not allow tag-num if there is no tag #151

dwapstra opened this issue Jan 17, 2021 · 5 comments

Comments

@dwapstra
Copy link
Contributor

If a package version does not have a tag, bumpver update --tag-num should not be allowed as it could create incorrect versions.

Example:

$ bumpver update --dry --tag-num
INFO    - Old Version: 21.1
INFO    - New Version: 21.11
--- bumpver.toml
+++ bumpver.toml
@@ -1,5 +1,5 @@
 [bumpver]
-current_version = "21.1"
+current_version = "21.11"
 version_pattern = "YY.MM[.PATCH][PYTAGNUM]"
 commit_message = "bump version {old_version} -> {new_version}"
 commit = true
--- src/mypkg/__init__.py
+++ src/mypkg/__init__.py
@@ -1,2 +1,2 @@
-__version__ = '21.1'
+__version__ = '21.11'
@mbarkhau
Copy link
Owner

That's a fair point. Are you interested in contributing a fix?

@dwapstra
Copy link
Contributor Author

That's a fair point. Are you interested in contributing a fix?

Sure, just need a pointer where to handle this.

@mbarkhau
Copy link
Owner

I think the most reasonable place to add this check would be in bumpver.v2version.incr: https://github.com/mbarkhau/bumpver/blob/master/src/bumpver/v2version.py#L724

Something similar to what is done at the end of the function:

def incr(...):
    ...
    has_tag_part = cur_vinfo.tag != "final"
    if tag_num and not has_tag_part:
        logger.error("Invalid arguments, non-final --tag=<tag> is needed to use --tag-num.")
        return None

Tests can be added here: https://github.com/mbarkhau/bumpver/blob/master/test/test_version.py

@dwapstra
Copy link
Contributor Author

Created PR #153

@mbarkhau
Copy link
Owner

Fixed with pip install "bumpver==2021.1109".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants