Skip to content

Commit

Permalink
RULEAPI-824 Sort tags by version number instead of commited date when…
Browse files Browse the repository at this point in the history
… computing coverage
  • Loading branch information
frederic-tingaud-sonarsource committed Dec 12, 2024
1 parent efa7462 commit 5fb2c9d
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion rspec-tools/rspec_tools/coverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,11 +195,18 @@ def checkout_repo(repo):
def is_version_tag(name):
return bool(re.fullmatch(VERSION_RE, name))


def comparable_version(key):
if not is_version_tag(key):
return [0]
return list(map(int, key.split('.')))


def collect_coverage_for_all_versions(repo, coverage):
git_repo = checkout_repo(repo)
tags = git_repo.tags
tags.sort(key = lambda t: t.commit.committed_date)
versions = [tag.name for tag in tags if is_version_tag(tag.name)]
versions.sort(key = comparable_version)
for version in versions:
collect_coverage_for_version(repo, git_repo, version, coverage)
collect_coverage_for_version(repo, git_repo, 'master', coverage)
Expand Down

0 comments on commit 5fb2c9d

Please sign in to comment.