-
-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathupdate_versions.py
More file actions
66 lines (54 loc) · 2.09 KB
/
update_versions.py
File metadata and controls
66 lines (54 loc) · 2.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/env python3
"""
Version update utility for SuperGemini Framework
Updates all hardcoded version strings to match VERSION file (SSOT)
"""
import re
from pathlib import Path
def get_version():
"""Read version from VERSION file"""
version_file = Path(__file__).parent / "VERSION"
if version_file.exists():
return version_file.read_text().strip()
else:
raise FileNotFoundError("VERSION file not found")
def update_file_versions(file_path: Path, old_version: str, new_version: str):
"""Update version strings in a single file"""
content = file_path.read_text()
# Pattern to match version strings (e.g., 4.0.3, 4.0.4)
pattern = re.compile(r'\b\d+\.\d+\.\d+\b')
# Replace all version-like strings that match the old version pattern
updated = False
new_content = content
for match in pattern.finditer(content):
version_str = match.group()
if version_str.startswith('4.0.'): # Only update SuperGemini versions
new_content = new_content.replace(version_str, new_version)
updated = True
if updated:
file_path.write_text(new_content)
print(f"Updated {file_path}")
return True
return False
def main():
"""Main function to update all version strings"""
# Get current version from VERSION file
new_version = get_version()
print(f"Updating all files to version {new_version}")
# Define directories to search
project_root = Path(__file__).parent
dirs_to_search = [
project_root / "setup",
project_root / "SuperGemini",
]
# Find and update Python files
updated_count = 0
for directory in dirs_to_search:
if directory.exists():
for py_file in directory.rglob("*.py"):
if update_file_versions(py_file, "4.0.3", new_version):
updated_count += 1
print(f"\nUpdated {updated_count} files to version {new_version}")
print("Note: This is a temporary solution. Files should be refactored to use dynamic version loading.")
if __name__ == "__main__":
main()