From 09ff5df2fb354a017afa02138b329e615a80c1d0 Mon Sep 17 00:00:00 2001 From: Maximilian Hils Date: Sat, 2 Jun 2018 21:37:44 +0200 Subject: Such CI, Very Wow. (#3182) --- mitmproxy/utils/debug.py | 16 ++---------- mitmproxy/version.py | 66 ++++++++++++++++++------------------------------ 2 files changed, 26 insertions(+), 56 deletions(-) (limited to 'mitmproxy') diff --git a/mitmproxy/utils/debug.py b/mitmproxy/utils/debug.py index e8eca906..c9ffb614 100644 --- a/mitmproxy/utils/debug.py +++ b/mitmproxy/utils/debug.py @@ -1,7 +1,6 @@ import gc import os import platform -import re import signal import sys import threading @@ -13,21 +12,10 @@ from mitmproxy import version def dump_system_info(): - mitmproxy_version = version.get_version(True, True) - mitmproxy_version = re.sub( - r"-0x([0-9a-f]+)", - r" (commit \1)", - mitmproxy_version - ) - - # PyInstaller builds indicator, if using precompiled binary - if getattr(sys, 'frozen', False): - bin_indicator = "binary" - else: - bin_indicator = "" + mitmproxy_version = version.get_dev_version() data = [ - "Mitmproxy: {} {}".format(mitmproxy_version, bin_indicator), + "Mitmproxy: {}".format(mitmproxy_version), "Python: {}".format(platform.python_version()), "OpenSSL: {}".format(SSL.SSLeay_version(SSL.SSLEAY_VERSION).decode()), "Platform: {}".format(platform.platform()), diff --git a/mitmproxy/version.py b/mitmproxy/version.py index fd0038b4..b40fae8b 100644 --- a/mitmproxy/version.py +++ b/mitmproxy/version.py @@ -1,9 +1,8 @@ import os import subprocess +import sys -# The actual version string. For precompiled binaries, this will be changed to include the build -# tag, e.g. "3.0.0.dev0042-0xcafeabc" -VERSION = "5.0.0" +VERSION = "5.0.0.dev" PATHOD = "pathod " + VERSION MITMPROXY = "mitmproxy " + VERSION @@ -12,50 +11,33 @@ MITMPROXY = "mitmproxy " + VERSION FLOW_FORMAT_VERSION = 7 -def get_version(dev: bool = False, build: bool = False, refresh: bool = False) -> str: +def get_dev_version() -> str: """ - Return a detailed version string, sourced either from a hardcoded VERSION constant - or obtained dynamically using git. - - Args: - dev: If True, non-tagged releases will include a ".devXXXX" suffix, where XXXX is the number - of commits since the last tagged release. - build: If True, non-tagged releases will include a "-0xXXXXXXX" suffix, where XXXXXXX are - the first seven digits of the commit hash. - refresh: If True, always try to use git instead of a potentially hardcoded constant. + Return a detailed version string, sourced either from VERSION or obtained dynamically using git. """ mitmproxy_version = VERSION - if "dev" in VERSION and not refresh: - pass # There is a hardcoded build tag, so we just use what's there. - elif dev or build: - here = os.path.abspath(os.path.join(os.path.dirname(__file__), "..")) - try: - git_describe = subprocess.check_output( - ['git', 'describe', '--long'], - stderr=subprocess.STDOUT, - cwd=here, - ) - last_tag, tag_dist, commit = git_describe.decode().strip().rsplit("-", 2) - commit = commit.lstrip("g")[:7] - tag_dist = int(tag_dist) - except Exception: - pass - else: - # Remove current suffix - mitmproxy_version = mitmproxy_version.split(".dev")[0] - - # Add suffix for non-tagged releases - if tag_dist > 0: - mitmproxy_version += ".dev{tag_dist}".format(tag_dist=tag_dist) - # The wheel build tag (we use the commit) must start with a digit, so we include "0x" - mitmproxy_version += "-0x{commit}".format(commit=commit) - - if not dev: - mitmproxy_version = mitmproxy_version.split(".dev")[0] - elif not build: - mitmproxy_version = mitmproxy_version.split("-0x")[0] + here = os.path.abspath(os.path.join(os.path.dirname(__file__), "..")) + try: + git_describe = subprocess.check_output( + ['git', 'describe', '--long'], + stderr=subprocess.STDOUT, + cwd=here, + ) + last_tag, tag_dist, commit = git_describe.decode().strip().rsplit("-", 2) + commit = commit.lstrip("g")[:7] + tag_dist = int(tag_dist) + except Exception: + pass + else: + # Add commit info for non-tagged releases + if tag_dist > 0: + mitmproxy_version += f" (+{tag_dist}, commit {commit})" + + # PyInstaller build indicator, if using precompiled binary + if getattr(sys, 'frozen', False): + mitmproxy_version += " binary" return mitmproxy_version -- cgit v1.2.3