diff options
author | jade <lix@jade.fyi> | 2024-06-11 04:45:12 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@localhost> | 2024-06-11 04:45:12 +0000 |
commit | 8a3d063a494c4b8c767190a5ce3e4075a75f9d07 (patch) | |
tree | 31ed3c6cdb149c56951658de2680a48fecfc57b0 /releng/gitutils.xsh | |
parent | f432e464dd1a11ef47b1487f1913cd9b5256c189 (diff) | |
parent | 82dc712d9312f06e653213d030b6db21529a422f (diff) |
Merge changes from topic "releng" into main
* changes:
releng: add prod environment, ready for release
releng: automatically figure out if we should tag latest for docker
releng: support multiarch docker images
manual: rewrite the docker guide now that we have images
Rewrite docker to be sensible and smaller
Implement docker upload in the releng tools
Diffstat (limited to 'releng/gitutils.xsh')
-rw-r--r-- | releng/gitutils.xsh | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/releng/gitutils.xsh b/releng/gitutils.xsh new file mode 100644 index 000000000..3352a6b21 --- /dev/null +++ b/releng/gitutils.xsh @@ -0,0 +1,37 @@ +import subprocess +import json + + +def version_compare(v1: str, v2: str): + return json.loads($(nix-instantiate --eval --json --argstr v1 @(v1) --argstr v2 @(v2) --expr '{v1, v2}: builtins.compareVersions v1 v2')) + + +def latest_tag_on_branch(branch: str) -> str: + return $(git describe --abbrev=0 @(branch) e>/dev/null).strip() + + +def is_maintenance_branch(branch: str) -> bool: + try: + main_tag = latest_tag_on_branch('main') + current_tag = latest_tag_on_branch(branch) + + return version_compare(current_tag, main_tag) < 0 + except subprocess.CalledProcessError: + # This is the case before Lix releases 2.90, since main *has* no + # release tag on it. + # FIXME: delete this case after 2.91 + return False + + +def verify_are_on_tag(): + current_tag = $(git describe --tag).strip() + assert current_tag == VERSION + + +def git_preconditions(): + # verify there is nothing in index ready to stage + proc = !(git diff-index --quiet --cached HEAD --) + assert proc.rtn == 0 + # verify there is nothing *stageable* and tracked + proc = !(git diff-files --quiet) + assert proc.rtn == 0 |