From db03c8aa16b9c4c325bb65b447ce97dacfcc38c5 Mon Sep 17 00:00:00 2001 From: Mike Hommey Date: Wed, 26 Jun 2024 06:25:22 +0900 Subject: [PATCH] Make download.py use the github release if --exact or HEAD point to a tag --- download.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/download.py b/download.py index 0b9da4bbc..330725b79 100755 --- a/download.py +++ b/download.py @@ -285,14 +285,28 @@ def main(args): tag = None local_sha1 = None - if build_commit: + if build_commit and not args.exact and not args.branch: try: local_sha1 = build_commit() except Exception: pass exact = args.exact or (not args.branch and local_sha1) - branch = args.branch or local_sha1 or 'release' + branch = args.branch or 'release' + + if build_commit and exact and not args.variant: + tags = [ + ref[len('refs/tags/'):] + for sha1, _, ref in ( + l.split(None, 2) + for l in subprocess.check_output( + ['git', 'for-each-ref', 'refs/tags/']).splitlines() + ) + if sha1.decode('ascii') == exact + ] + tags = sorted(tags, key=lambda x: split_version(x), reverse=True) + if tags: + tag = tags[0].decode('ascii') if exact: sha1 = exact