From 12ea25c3f2c57bbe14d40cee8705b3f496559b3e Mon Sep 17 00:00:00 2001 From: makamys Date: Sat, 10 Jun 2023 21:58:50 +0200 Subject: [PATCH] Make update checker print a summary and use return codes --- scripts/check_upstream.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/scripts/check_upstream.py b/scripts/check_upstream.py index b2d8e34..6d53e0a 100644 --- a/scripts/check_upstream.py +++ b/scripts/check_upstream.py @@ -11,6 +11,7 @@ from pathlib import Path import sys cachedGithubToken = None +foundUpdates = 0 if not Path("module-mixin").is_dir(): sys.exit(''' @@ -24,11 +25,14 @@ def compareVersions(rootName, comparisons): compareVersion(f"{rootName} ({name})", a, b) def compareVersion(name, a, b): + global foundUpdates + upToDate = a == b judgement = "Up to date" if upToDate else "Out of sync!" details = f"({a} << {b})" if not upToDate: print(f"{name}: {judgement} {details}") + foundUpdates += 1 def property(text, propName): props = dict([line.split("=") for line in text.splitlines() if line]) @@ -130,3 +134,10 @@ compareVersions("Mixingasm", compareVersions("SpongeMixins", creditsSources("module-spongemixins")) + +if not foundUpdates: + print("All modules up to date.") +else: + print() + print(foundUpdates, "repositories are out of sync.") + sys.exit(1)