A check in order not to update twice

Signed-off-by: Pedro Algarvio <palgarvio@vmware.com>
This commit is contained in:
Pedro Algarvio 2022-08-10 20:37:17 +01:00 committed by Pedro Algarvio
parent 50dd136e9a
commit 808a1bc277

View file

@ -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])