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

[usage question] Bumping patch while removing post? #174

Closed
bsolomon1124 opened this issue Nov 16, 2020 · 3 comments
Closed

[usage question] Bumping patch while removing post? #174

bsolomon1124 opened this issue Nov 16, 2020 · 3 comments

Comments

@bsolomon1124
Copy link

bsolomon1124 commented Nov 16, 2020

We follow a versioning scheme that is mostly PEP 440 with some tweaks:

  • no 'implicit 0' after pre-release or post-release suffixes, e.g. .dev0 is required, not .dev
  • major.minor.patch required to be explicit

It comes down to 4 'groups' of versions as shown below:

1.2.3             # (1) final

1.2.3.dev0        # (2) prerelease
1.2.3.a0
1.2.3.alpha0
1.2.3.b0
1.2.3.beta0
1.2.3.rc0

1.2.3.rc3.post0   # (3) postrelease (of a pre-release version)

1.2.3.post0       # (4) postrelease (of a final version)

Regex example: https://regex101.com/r/wupvcm/1

Reproducible single-file project:

cat << EOF > __init__.py
__version__ = "1.0.0.a2.post0"
EOF

cat << EOF > setup.cfg
[bumpversion]
current_version = 1.0.0.a2.post0
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)(\.(?P<pre>(?:a|alpha|b|beta|d|dev|rc)\d+))?(\.(?P<post>post\d+))?
tag = True
commit = True
serialize =
  {major}.{minor}.{patch}
  {major}.{minor}.{patch}.{post}
  {major}.{minor}.{patch}.{pre}
  {major}.{minor}.{patch}.{pre}.{post}

[bumpversion:file:__init__.py]
EOF

Now we run:

$ bump2version --new-version 1.0.0.a3 pre

Actual result:

$ cat __init__.py 
__version__ = "1.0.0.a3.0"

Expected result:

$ cat __init__.py 
__version__ = "1.0.0.a3"

What would be the proper invocation or configuration to (1) remove the .postX while (2) bumping the pre segment from a2 to a3?

@bsolomon1124
Copy link
Author

Left a similar question with some scheme modifications on Stack Overflow: https://stackoverflow.com/q/65083808/7954504.

@pdemarti
Copy link

pdemarti commented Dec 10, 2020

Please see my answer on StackOverflow.

Since pre and post each have both a string prefix and a number, I believe it is necessary to split them accordingly. For example, the pre part could be split into a prekind (the string) and a pre (the number). Then, the nice thing is that you can increment prekind ('dev' to 'alpha' to 'beta' etc.) independently of the issue number (a sequence, as usual).

On the answer linked above, I've put both a complete configuration and an example with a number of invocations in sequence to show the various mutations that are possible.

@bsolomon1124
Copy link
Author

Closing as the linked answer seems to be a full-fledged working solution.

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

No branches or pull requests

3 participants