Skip to content

Commit

Permalink
programs: fix regex to match multi-digit major version
Browse files Browse the repository at this point in the history
In a3679a6 (programs: favor version numbers with dots, 2025-01-03) we
have changed the regex used to extract version numbers to favor dotted
versions. It was reported though that the regex doesn't match major
version numbers that start with multiple digits correctly. Fix this.

Signed-off-by: Patrick Steinhardt <[email protected]>
  • Loading branch information
pks-t authored and eli-schwartz committed Jan 8, 2025
1 parent 5af3d3d commit 27028bd
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion mesonbuild/programs.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def get_version(self, interpreter: T.Optional['Interpreter'] = None) -> str:
if not output:
output = e.strip()

match = re.search(r'([0-9](\.[0-9]+)+)', output)
match = re.search(r'([0-9]+(\.[0-9]+)+)', output)
if not match:
match = re.search(r'([0-9][0-9\.]+)', output)
if not match:
Expand Down
1 change: 1 addition & 0 deletions unittests/internaltests.py
Original file line number Diff line number Diff line change
Expand Up @@ -689,6 +689,7 @@ def test_program_version(self):
'foo 1.2.4.': '1.2.4',
'foo 1.2.4': '1.2.4',
'foo 1.2.4 bar': '1.2.4',
'foo 10.0.0': '10.0.0',
'50 5.4.0': '5.4.0',
'This is perl 5, version 40, subversion 0 (v5.40.0)': '5.40.0',
'git version 2.48.0.rc1': '2.48.0',
Expand Down

0 comments on commit 27028bd

Please sign in to comment.