ups/scripts/check.py
ngn ab580d6a18
Some checks failed
format / build (push) Failing after 6s
initial commit
Signed-off-by: ngn <ngn@ngn.tf>
2025-05-02 18:20:24 +03:00

44 lines
1.0 KiB
Python

#!/bin/python3
from ups import log
import ups
def check(dir=".") -> bool:
try:
us = ups.upstream(dir=dir)
except Exception as e:
log.fail("failed to create ups upstream", exception=e)
return False
try:
commits = us.last()
except Exception as e:
log.fail("failed to get commits: %s" % e)
return False
if len(commits) == 0:
log.info("upstream does not have any commits")
return True
last_commit = commits[0]
saved_commit = us.commit()
if saved_commit == "":
log.warn("no commit specified, assuming we are on the latest commit")
us.commit(last_commit)
return False
if saved_commit == last_commit:
log.info("up-to-date with the upstream")
return True
commits = us.until(saved_commit)
log.warn("%d commits behind the upstream" % len(commits))
log.info("run ups-update to pull & apply patches")
return False
if "__main__" == __name__:
exit(0 if check() else 1)