Skip to content
This repository was archived by the owner on Aug 29, 2020. It is now read-only.
Prev Previous commit
Relaxed label matching
  • Loading branch information
andreasohlund committed Oct 7, 2016
commit 7f1da5bc1bae312be23082ad43b32b0670eaee93
13 changes: 13 additions & 0 deletions src/Compiler/IssueExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
namespace ReleaseNotesCompiler
{
using System.Linq;
using Octokit;

static class IssueExtensions
{
public static bool IsBug(this Issue issue)
{
return issue.Labels.Any(label => label.Name == "Type: Bug" || label.Name == "Bug");
}
}
}
6 changes: 2 additions & 4 deletions src/Compiler/ReleaseNotesBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ public ReleaseNotesBuilder(IGitHubClient gitHubClient, string user, string repos
this.milestoneTitle = milestoneTitle;
}

public static string LabelPrefix => "Type: ";

public async Task<string> BuildReleaseNotes()
{
var milestones = await gitHubClient.GetMilestones();
Expand Down Expand Up @@ -93,7 +91,7 @@ string GetCommitsLink(Milestone targetMilestone, Milestone previousMilestone)
void AddIssues(StringBuilder builder, List<Issue> issues)
{
var bugs = issues
.Where(issue => issue.Labels.Any(label => label.Name == "Type: Bug"))
.Where(issue => issue.IsBug())
.ToList();

if (bugs.Any())
Expand All @@ -105,7 +103,7 @@ void AddIssues(StringBuilder builder, List<Issue> issues)
builder.AppendLine();
}

var others = issues.Where(issue => !issue.Labels.Any() || issue.Labels.Any(label => label.Name != "Type: Refactoring" && label.Name != "Type: Bug"))
var others = issues.Where(issue =>!issue.IsBug())
.ToList();

if (others.Any())
Expand Down
1 change: 1 addition & 0 deletions src/Compiler/ReleaseNotesCompiler.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
<Compile Include="AssemblyInfo.cs" />
<Compile Include="DefaultGitHubClient.cs" />
<Compile Include="IGitHubClient.cs" />
<Compile Include="IssueExtensions.cs" />
<Compile Include="ReleaseNotesBuilder.cs" />
<Compile Include="OctokitExtensions.cs" />
<Compile Include="ReleaseUpdateRequired.cs" />
Expand Down
4 changes: 2 additions & 2 deletions src/Tests/ReleaseNotesBuilderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,12 @@ static Issue CreateIssue(int number, params string[] labels)
"Some issue",
null,
null,
labels.Select(x => new Label(null, ReleaseNotesBuilder.LabelPrefix + x, null)).ToArray(),
labels.Select(x => new Label(null, x, null)).ToArray(),
null,
null,
0,
null,
null,
null,
DateTimeOffset.Now,
null,
1,
Expand Down