mirror of
https://github.com/terrapkg/packages.git
synced 2026-06-06 20:02:18 +00:00
7653e48da9
this was an L and i probably need sleep
31 lines
677 B
Python
31 lines
677 B
Python
import requests
|
|
import re
|
|
import os
|
|
|
|
|
|
NAME = "openasar-canary"
|
|
REPO = "GooseMod/OpenAsar"
|
|
REGEX_SHA = r"%define commit (.+)"
|
|
SPEC = f"{NAME}.spec"
|
|
LINK = f"https://api.github.com/repos/{REPO}/commits/HEAD"
|
|
|
|
token = os.getenv("GITHUB_TOKEN")
|
|
sha = requests.get(LINK, headers={"Authorization": f"Bearer {token}"}).json()["sha"]
|
|
f = open(SPEC, "r")
|
|
|
|
matches = re.findall(REGEX_SHA, txt := f.read())
|
|
if not len(matches):
|
|
exit(f"{NAME}: Failed to match regex!")
|
|
cur = matches[0]
|
|
|
|
if sha == cur:
|
|
exit(f"{NAME}: Up to date!")
|
|
print(f"{NAME}: {cur} -> {sha}")
|
|
|
|
newspec = re.sub(REGEX_SHA, f"%define commit {sha}", txt)
|
|
|
|
f.close()
|
|
f = open(SPEC, "w")
|
|
f.write(newspec)
|
|
f.close()
|