-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathversion-select.py
More file actions
68 lines (50 loc) · 1.51 KB
/
Copy pathversion-select.py
File metadata and controls
68 lines (50 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import subprocess
import sys
# ===== CONFIG =====
SCRIPT_TO_RUN = ["build.bat"]
DEFAULT_TAG = "latest"
# ==================
def get_git_tags():
repo_url = "https://github.com/ArchipelagoMW/Archipelago.git"
result = subprocess.run(
["git", "ls-remote", "--tags", repo_url],
capture_output=True,
text=True,
check=True
)
tags = set()
for line in result.stdout.splitlines():
ref = line.split("\t")[1]
if ref.endswith("^{}"):
ref = ref[:-3]
tags.add(ref.split("/")[-1])
return sorted(tags)
def main():
try:
tags = get_git_tags()
except subprocess.CalledProcessError as e:
print("Error: not a git repository or git not available")
sys.exit(1)
if not tags:
print("No git tags found.")
sys.exit(1)
tags = sorted(tags)
tags_set = set(tags)
print("Available git tags:")
print("-------------------")
for tag in tags:
print(tag)
print()
selected_tag = input(f"Enter tag name [default: {DEFAULT_TAG}]: ").strip()
if not selected_tag:
selected_tag = DEFAULT_TAG
print(f"Using default tag: {DEFAULT_TAG}")
if selected_tag not in tags_set and selected_tag != "latest":
print(f"\nTag '{selected_tag}' not found.")
sys.exit(1)
print(f"\nSelected tag: {selected_tag}\n")
subprocess.run(SCRIPT_TO_RUN + [selected_tag], check=True)
print("Finished. Press enter to exit")
input()
if __name__ == "__main__":
main()