From e1849540e32df104697d8b518316775e0f5d638c Mon Sep 17 00:00:00 2001
From: Freddy Heppell <frheppell1@sheffield.ac.uk>
Date: Fri, 12 Jan 2024 13:14:27 +0000
Subject: [PATCH] Remove README version check and update

---
 version.py | 37 +------------------------------------
 1 file changed, 1 insertion(+), 36 deletions(-)

diff --git a/version.py b/version.py
index 51faf08f..0eeb1825 100644
--- a/version.py
+++ b/version.py
@@ -8,8 +8,6 @@
 DOCS_PACKAGE_JSON_FILE_PATH = "docs/package.json"
 CITATION_FILE_PATH = "CITATION.cff"
 MASTER_VERSION_FILE = "VERSION"
-README_FILE_PATH = "README.md"
-README_VERSION_REGEX = r"\(Version ([^)]*)\)"
 
 def check():
     """
@@ -30,13 +28,10 @@ def check():
     citation_version = citation_file['version']
     print(f"{CITATION_FILE_PATH} version is {citation_version}")
 
-    readme_version = get_readme_version(README_FILE_PATH)
-    print(f"{README_FILE_PATH} version is {readme_version}")
-
     master_version = get_master_version()
     print(f"VERSION file version is {master_version}")
 
-    if js_version != master_version or docs_js_version != master_version or citation_version != master_version or readme_version != master_version:
+    if js_version != master_version or docs_js_version != master_version or citation_version != master_version:
         print("One or more versions does not match")
         sys.exit(1)
     else:
@@ -49,21 +44,6 @@ def get_package_json_version(file_path: str) -> str:
     js_version = package_json['version']
     return js_version
 
-def get_readme_version(file_path: str) -> str:
-    with open(file_path, 'r') as f:
-        readme_text = f.read()
-    
-    match = re.search(README_VERSION_REGEX, readme_text)
-
-    if match is None:
-        print(f"No version found in {README_FILE_PATH}.")
-        return
-    elif len(match.groups()) > 1:
-        print(f"{len(match.groups())} matches found in {README_FILE_PATH}, expected 1.")
-        return
-    else:
-        return match.groups(1)[0]
-
 def get_master_version():
     with open(MASTER_VERSION_FILE, "r") as f:
             master_version = f.readline().strip()
@@ -83,8 +63,6 @@ def update(master_version:str = None):
 
     update_package_json_version(DOCS_PACKAGE_JSON_FILE_PATH, master_version)
 
-    update_readme_version(README_FILE_PATH, master_version)
-
     with open(CITATION_FILE_PATH, "r") as f:
         citation_file = yaml.safe_load(f)
     print(f"Writing master version {master_version} to {CITATION_FILE_PATH}")
@@ -102,19 +80,6 @@ def update_package_json_version(file_path:str, version_no:str):
         package_json['version'] = version_no
         json.dump(package_json, f, indent=2)
 
-def update_readme_version(file_path:str, version_no:str):
-    with open(file_path, 'r') as f:
-        readme_text = f.read()
-    
-    readme_text = re.sub(
-           README_VERSION_REGEX, 
-           f'(Version {version_no})', 
-           readme_text
-       )
-
-    with open(file_path, 'w') as f:
-        f.write(readme_text)
-
 
 if __name__ == "__main__":
     if sys.argv[1] == 'check':