1
0
Fork 0

Fix regex to replace version in manifest

This regex is used to find (textually, not via toml parser) where to replace the
version number in the Manifest.

Until now it was only supporting version numbers containing dots and digits.
I changed that to version numbers containing anything but ~ and " to handle version
numbers with dashes, or manually written version numbers that might be invalid (if
someone litteraly writes `version = "x.y~ynh1"). We don’t actually care about the
version number we match against because we just replace it.
This commit is contained in:
Félix Piédallu 2024-03-06 23:10:48 +01:00 committed by Bram
parent 78e5e21deb
commit 48c41dad9b

View file

@ -480,7 +480,7 @@ class AppAutoUpdater:
if is_main:
def repl(m: re.Match) -> str:
return m.group(1) + new_version + '~ynh1"'
content = re.sub(r"(\s*version\s*=\s*[\"\'])([\d\.]+)(\~ynh\d+[\"\'])", repl, content)
content = re.sub(r"(\s*version\s*=\s*[\"\'])([^~\"\']+)(\~ynh\d+[\"\'])", repl, content)
for old, new in replacements:
content = content.replace(old, new)