diff --git a/docs/subsystems/dependencies.md b/docs/subsystems/dependencies.md index 9335eaa5db..4fa3512275 100644 --- a/docs/subsystems/dependencies.md +++ b/docs/subsystems/dependencies.md @@ -43,7 +43,7 @@ In `version.py`, we have a special parameter, `PROVISION_VERSION`, which is used to help ensure developers don't spend time debugging test/linter/etc. failures that actually were caused by the developer rebasing and forgetting to provision". `PROVISION_VERSION` has a -format of `x.y`; when `x` doesn't match the value from the last time +format of `(x, y)`; when `x` doesn't match the value from the last time the user provisioned, or `y` is higher than the value from last time, most Zulip tools will crash early and ask the user to provision. This has empirically made a huge impact on how often developers spend diff --git a/tools/diagnose b/tools/diagnose index 1b05167c38..b29375b55c 100755 --- a/tools/diagnose +++ b/tools/diagnose @@ -76,12 +76,12 @@ def check_django() -> bool: def provision_version() -> bool: fn = os.path.join(UUID_VAR_PATH, "provision_version") with open(fn) as f: - version = f.read().strip() + version = tuple(map(int, f.read().strip().split("."))) print("latest version provisioned:", version) from version import PROVISION_VERSION print("desired version:", PROVISION_VERSION) - if version != PROVISION_VERSION: + if not (PROVISION_VERSION <= version < (PROVISION_VERSION[0] + 1,)): print("You need to provision!") return False return True diff --git a/tools/lib/provision_inner.py b/tools/lib/provision_inner.py index c77f70eb33..acc1856ff0 100755 --- a/tools/lib/provision_inner.py +++ b/tools/lib/provision_inner.py @@ -362,7 +362,7 @@ def main(options: argparse.Namespace) -> int: version_file = os.path.join(UUID_VAR_PATH, "provision_version") print(f"writing to {version_file}\n") with open(version_file, "w") as f: - f.write(PROVISION_VERSION + "\n") + f.write(".".join(map(str, PROVISION_VERSION)) + "\n") print() print(OKBLUE + "Zulip development environment setup succeeded!" + ENDC) diff --git a/tools/lib/test_script.py b/tools/lib/test_script.py index 07e767bd32..aefd1582d5 100644 --- a/tools/lib/test_script.py +++ b/tools/lib/test_script.py @@ -3,7 +3,6 @@ import os import subprocess import sys from argparse import ArgumentParser -from distutils.version import LooseVersion from typing import Iterable, List, Optional, Tuple from scripts.lib.zulip_tools import get_dev_uuid_var_path @@ -12,10 +11,6 @@ from version import PROVISION_VERSION ZULIP_PATH = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) -def get_major_version(v: str) -> int: - return int(v.split(".")[0]) - - def get_version_file() -> str: uuid_var_path = get_dev_uuid_var_path() return os.path.join(uuid_var_path, "provision_version") @@ -30,7 +25,7 @@ properly. """ -def preamble(version: str) -> str: +def preamble(version: Tuple[int, ...]) -> str: text = PREAMBLE.format(version, PROVISION_VERSION) text += "\n" return text @@ -64,21 +59,16 @@ def get_provisioning_status() -> Tuple[bool, Optional[str]]: return True, None with open(version_file) as f: - version = f.read().strip() - - # Normal path for people that provision--we're all good! - if version == PROVISION_VERSION: - return True, None + version = tuple(map(int, f.read().strip().split("."))) # We may be more provisioned than the branch we just moved to. As # long as the major version hasn't changed, then we should be ok. - if LooseVersion(version) > LooseVersion(PROVISION_VERSION): - if get_major_version(version) == get_major_version(PROVISION_VERSION): - return True, None - else: - return False, preamble(version) + NEED_TO_DOWNGRADE - - return False, preamble(version) + NEED_TO_UPGRADE + if version < PROVISION_VERSION: + return False, preamble(version) + NEED_TO_UPGRADE + elif version < (PROVISION_VERSION[0] + 1,): + return True, None + else: + return False, preamble(version) + NEED_TO_DOWNGRADE def assert_provisioning_status_ok(skip_provision_check: bool) -> None: diff --git a/version.py b/version.py index d58ea178fa..a364e21503 100644 --- a/version.py +++ b/version.py @@ -48,4 +48,4 @@ API_FEATURE_LEVEL = 133 # historical commits sharing the same major version, in which case a # minor version bump suffices. -PROVISION_VERSION = "195.0" +PROVISION_VERSION = (195, 0)