diff options
author | Jason R. Coombs <jaraco@jaraco.com> | 2013-05-24 16:30:20 -0400 |
---|---|---|
committer | Jason R. Coombs <jaraco@jaraco.com> | 2013-05-24 16:30:20 -0400 |
commit | 0465490edb621f16353aa5ac7d9661cf69accf8b (patch) | |
tree | f598451e6e128feb94ab2cc6d1fe450633e410ce | |
parent | f1427c0e80b583800c59f4013d08b45a4cbb8250 (diff) | |
download | external_python_setuptools-0465490edb621f16353aa5ac7d9661cf69accf8b.tar.gz external_python_setuptools-0465490edb621f16353aa5ac7d9661cf69accf8b.tar.bz2 external_python_setuptools-0465490edb621f16353aa5ac7d9661cf69accf8b.zip |
Updated get_next_version to bump arbitrary versions and added doctests.
-rw-r--r-- | release.py | 30 |
1 files changed, 25 insertions, 5 deletions
@@ -25,12 +25,32 @@ except Exception: VERSION = '0.7b1' PACKAGE_INDEX = 'https://pypi.python.org/pypi' -def get_next_version(): - digits = map(int, VERSION.split('.')) - digits[-1] += 1 - return '.'.join(map(str, digits)) +def get_next_version(version): + """ + Infer a next version from the current version by incrementing the last + number or appending a number. + + >>> get_next_version('1.0') + '1.1' + + >>> get_next_version('1.0b') + '1.0b1' + + >>> get_next_version('1.0.9') + '1.0.10' + + >>> get_next_version('1') + '2' + + >>> get_next_version('') + '1' + """ + def incr(match): + ver = int(match.group(0) or '0') + return str(ver + 1) + return re.sub('\d*$', incr, version) -NEXT_VERSION = get_next_version() +NEXT_VERSION = get_next_version(VERSION) files_with_versions = 'docs/conf.py', 'setup.py', 'release.py', 'ez_setup.py' |