Skip to content

Commit

Permalink
Fix coverage to use line coverage instead of method coverage when cre…
Browse files Browse the repository at this point in the history
…ating badge for coverage results
  • Loading branch information
xoofx committed Feb 9, 2024
1 parent 7a09f53 commit 6437a11
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/dotnet-releaser/ReleaserApp.BuildAndTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,12 @@ private async Task<bool> BuildAndTest(IDevHosting? devHosting, BuildInformation
{
if (_config.Coverage.Enable)
{
var coverageResult = LoadAndDisplayCoverageResults();
var lineCoverageResult = LoadAndDisplayCoverageResults();

// Publish badge if requested
if (devHosting is not null)
{
await PublishCoverageToGist(devHosting, buildInfo, coverageResult);
await PublishCoverageToGist(devHosting, buildInfo, lineCoverageResult);
}
}

Expand Down Expand Up @@ -160,7 +160,7 @@ private HitCoverage LoadAndDisplayCoverageResults()

_logger.InfoMarkup("Coverage Results:", table);

return totalMethodRate;
return totalLineRate;
}

private async Task<bool> Build(string projectFile, bool isTestProject)
Expand Down
4 changes: 2 additions & 2 deletions src/dotnet-releaser/ReleaserApp.Coverage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace DotNetReleaser;

public partial class ReleaserApp
{
private async Task PublishCoverageToGist(IDevHosting devHosting, BuildInformation buildInfo, HitCoverage coverage)
private async Task PublishCoverageToGist(IDevHosting devHosting, BuildInformation buildInfo, HitCoverage lineCoverage)
{
if (!_config.Coverage.BadgeUploadToGist || !buildInfo.IsPush) return;

Expand All @@ -24,7 +24,7 @@ private async Task PublishCoverageToGist(IDevHosting devHosting, BuildInformatio
return;
}

var rate = (int)Math.Round((double)coverage.Rate * 100);
var rate = (int)Math.Round((double)lineCoverage.Rate * 100);

// TODO: We could make many of these things configurable (colors, size of the badge, etc.)
var color = rate switch
Expand Down

0 comments on commit 6437a11

Please sign in to comment.