Allow writing commit with version bump

This commit is contained in:
Paulus Schoutsen 2018-06-21 17:27:01 -04:00
parent 0df99f8762
commit 35b609dd8b

View File

@ -2,6 +2,7 @@
"""Helper script to bump the current version.""" """Helper script to bump the current version."""
import argparse import argparse
import re import re
import subprocess
from packaging.version import Version from packaging.version import Version
@ -117,12 +118,20 @@ def main():
help="The type of the bump the version to.", help="The type of the bump the version to.",
choices=['beta', 'dev', 'patch', 'minor'], choices=['beta', 'dev', 'patch', 'minor'],
) )
parser.add_argument(
'--commit', action='store_true',
help='Create a version bump commit.')
arguments = parser.parse_args() arguments = parser.parse_args()
current = Version(const.__version__) current = Version(const.__version__)
bumped = bump_version(current, arguments.type) bumped = bump_version(current, arguments.type)
assert bumped > current, 'BUG! New version is not newer than old version' assert bumped > current, 'BUG! New version is not newer than old version'
write_version(bumped) write_version(bumped)
if not arguments.commit:
return
subprocess.run(['git', 'commit', '-am', f'Bumped version to {bumped}'])
def test_bump_version(): def test_bump_version():
"""Make sure it all works.""" """Make sure it all works."""