diff options
author | Maximilian Hils <git@maximilianhils.com> | 2017-12-27 21:46:52 +0100 |
---|---|---|
committer | Maximilian Hils <git@maximilianhils.com> | 2017-12-30 18:48:47 +0100 |
commit | 9dc3d16bf2554ca1fb6d191c232d096fe0774110 (patch) | |
tree | ac384e883a451d28ef312c94e0909ca4da88fe41 /release | |
parent | 937a849c9363b1fb745b0948310533b535348819 (diff) | |
download | mitmproxy-9dc3d16bf2554ca1fb6d191c232d096fe0774110.tar.gz mitmproxy-9dc3d16bf2554ca1fb6d191c232d096fe0774110.tar.bz2 mitmproxy-9dc3d16bf2554ca1fb6d191c232d096fe0774110.zip |
single-source version processing
Diffstat (limited to 'release')
-rwxr-xr-x | release/rtool.py | 29 |
1 files changed, 6 insertions, 23 deletions
diff --git a/release/rtool.py b/release/rtool.py index 14a0a078..4a07885c 100755 --- a/release/rtool.py +++ b/release/rtool.py @@ -81,35 +81,18 @@ def git(args: str) -> str: def get_version(dev: bool = False, build: bool = False) -> str: - version = runpy.run_path(VERSION_FILE)["VERSION"] - version = re.sub(r"\.dev.+?$", "", version) # replace dev suffix if present. - - last_tag, tag_dist, commit = git("describe --tags --long").strip().rsplit("-", 2) - commit = commit.lstrip("g")[:7] - tag_dist = int(tag_dist) - - if tag_dist > 0 and dev: - dev_tag = ".dev{tag_dist:04}".format(tag_dist=tag_dist) - else: - dev_tag = "" - - if tag_dist > 0 and build: - # The wheel build tag (we use the commit) must start with a digit, so we include "0x" - build_tag = "-0x{commit}".format(commit=commit) - else: - build_tag = "" - - return version + dev_tag + build_tag + x = runpy.run_path(VERSION_FILE) + return x["get_version"](dev, build, True) def set_version(dev: bool) -> None: """ - Update version information in mitmproxy's version.py to either include the dev version or not. + Update version information in mitmproxy's version.py to either include hardcoded information or not. """ - v = get_version(dev) - with open(VERSION_FILE) as f: + version = get_version(dev, dev) + with open(VERSION_FILE, "r") as f: content = f.read() - content = re.sub(r'^VERSION = ".+?"', 'VERSION = "{}"'.format(v), content) + content = re.sub(r'^VERSION = ".+?"', 'VERSION = "{}"'.format(version), content, flags=re.M) with open(VERSION_FILE, "w") as f: f.write(content) |