From 808a1bc277692e9484e10ab9e355b677e2e6c894 Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Wed, 10 Aug 2022 20:37:17 +0100 Subject: [PATCH] A check in order not to update twice Signed-off-by: Pedro Algarvio --- .github/workflows/scripts/update-release-shasum.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.github/workflows/scripts/update-release-shasum.py b/.github/workflows/scripts/update-release-shasum.py index 60a6600..46e38a0 100644 --- a/.github/workflows/scripts/update-release-shasum.py +++ b/.github/workflows/scripts/update-release-shasum.py @@ -1,6 +1,7 @@ #!/usr/bin/env python import sys import pathlib +import subprocess THIS_FILE = pathlib.Path(__file__).resolve() CODE_ROOT = THIS_FILE.parent.parent.parent.parent @@ -9,6 +10,9 @@ README_PATH = CODE_ROOT / "README.rst" def main(version, sha256sum): in_contents = README_PATH.read_text() + if version in in_contents: + print(f"README file already contains an entry for version {version}") + sys.exit(1) out_contents = "" found_anchor = False updated_version = False @@ -32,6 +36,14 @@ def main(version, sha256sum): if in_contents != out_contents: README_PATH.write_text(out_contents) + ret = subprocess.run( + ["git", "diff", "--stat"], universal_newlines=True, capture_output=True + ) + if "1 file changed, 1 insertion(+)" not in ret.stdout: + print("Too Many Changes to the readme file") + sys.exit(1) + sys.exit(0) + if __name__ == "__main__": main(sys.argv[1], sys.argv[2])