publish update.py

This commit is contained in:
brockdarnold 2026-06-15 00:11:30 +00:00
parent 83c049f829
commit fe98ad78d8

View file

@ -74,7 +74,8 @@ ZIP_URL = "https://git.armoredarmadillo.com/brockdarnold/eve-watcher/archive/mai
def _git(*a): def _git(*a):
return subprocess.run(["git", "-C", HERE, *a], capture_output=True, text=True) env = dict(os.environ, GIT_TERMINAL_PROMPT="0") # never block on an interactive prompt
return subprocess.run(["git", "-C", HERE, *a], capture_output=True, text=True, env=env)
def _have_git(): def _have_git():
@ -89,9 +90,11 @@ def update_code():
if _have_git(): if _have_git():
before = _git("rev-parse", "HEAD").stdout.strip() before = _git("rev-parse", "HEAD").stdout.strip()
if _git("fetch", "-q", "origin").returncode != 0: if _git("fetch", "-q", "origin").returncode != 0:
print("! git fetch failed (offline?). Keeping current version.") print("! git fetch failed — falling back to zip update.")
return False return _zip_update()
_git("reset", "--hard", "-q", "origin/main") if _git("reset", "--hard", "-q", "origin/main").returncode != 0:
print("! git reset failed (locked .git pack?) — falling back to zip update.")
return _zip_update() # zip writes files directly, no .git pack to unlink
after = _git("rev-parse", "HEAD").stdout.strip() after = _git("rev-parse", "HEAD").stdout.strip()
if before and after and before != after: if before and after and before != after:
print(f" updated: {before[:7]} -> {after[:7]}") print(f" updated: {before[:7]} -> {after[:7]}")