From 3b745315e47c13c3ec5e8ae0d7fb416da2884d34 Mon Sep 17 00:00:00 2001 From: Marco Borgeaud Date: Mon, 16 Dec 2024 15:38:14 +0100 Subject: [PATCH] Only support tags >= 9 Loosen regex to detect unexpectedly missing version in the future. --- rspec-tools/rspec_tools/coverage.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/rspec-tools/rspec_tools/coverage.py b/rspec-tools/rspec_tools/coverage.py index 70cc866f645..9c24ea929cb 100644 --- a/rspec-tools/rspec_tools/coverage.py +++ b/rspec-tools/rspec_tools/coverage.py @@ -49,7 +49,7 @@ RULES_FILENAME = 'covered_rules.json' -DEPENDENCY_RE = re.compile(r'''\bdependency\s+['"](?:com|org)\.sonarsource\.[\w.-]+:(?P[\w-]+):(?P\d+(\.\d+)+)['"]''') +DEPENDENCY_RE = re.compile(r'''\bdependency\s+['"](?:com|org)\.sonarsource\.[\w.-]+:(?P[\w-]+):(?P\d+(\.\d+)+)?''') BUNDLED_SIMPLE = r'''['"](?:com|org)\.sonarsource\.[\w.-]+:(?P[\w-]+)['"]''' BUNDLED_MULTI = r'''\(\s*group:\s*['"][\w.-]+['"],\s*name:\s*['"](?P[\w-]+)['"],\s*classifier:\s*['"][\w-]+['"]\s*\)''' @@ -262,6 +262,10 @@ def get_plugin_versions(git_repo, version): content = g.show(f'{version}:build.gradle') versions = {} for m in re.finditer(DEPENDENCY_RE, content): + if m['plugin_name'] in ['sonar-plugin-api', 'sonar-plugin-api-test-fixtures']: + # Ignore these "plugins". They may not have a numerical version. + continue + assert m['version'], f'Failed to find version from dependency {m[0]}' versions[m['plugin_name']] = m['version'] return versions @@ -360,7 +364,7 @@ def is_interesting_version(version): major = int(version[:version.find('.')]) except ValueError: return False - return major >= 8 + return major >= 9 def collect_coverage_per_product(): git_repo = checkout_repo('sonar-enterprise')