Skip to content
This repository was archived by the owner on Aug 29, 2020. It is now read-only.
Prev Previous commit
Next Next commit
Include unlabeled issues/pulls
  • Loading branch information
andreasohlund committed Oct 6, 2016
commit f2f22afadf7a1a407178e84e0895f856c7ddb73b
52 changes: 35 additions & 17 deletions src/Compiler/ReleaseNotesBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,32 @@ string GetCommitsLink(Milestone previousMilestone)
return string.Format("https://github.com/{0}/{1}/compare/{2}...{3}", user, repository, previousMilestone.Title, targetMilestone.Title);
}

void AddIssues(StringBuilder stringBuilder, List<Issue> issues)
void AddIssues(StringBuilder builder, List<Issue> issues)
{
Append(issues, "Feature", stringBuilder);
Append(issues, "Bug", stringBuilder);
var bugs = issues
.Where(issue => issue.Labels.Any(label => label.Name == "Type: Bug"))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about Contains("Bug") ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't that to wide, what if there is a label that contains those characters?

How about:

issue => issue.Labels.Any(label => label.Name == "Type: Bug" || label.Name == "Bug"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good with that either as of now (maybe some repo decided to have a Critical Bug or Type:Bug label which would break this impl. but good to skip that as of now.

.ToList();

if (bugs.Any())
{
PrintHeading("Bugs", builder);

PrintIssue(builder, bugs);

builder.AppendLine();
}

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

if (others.Any())
{
PrintHeading("Improvements/Features", builder);

PrintIssue(builder, others);

builder.AppendLine();
}
}

static async Task AddFooter(StringBuilder stringBuilder)
Expand All @@ -121,22 +143,18 @@ static async Task AddFooter(StringBuilder stringBuilder)
}
}

void Append(IEnumerable<Issue> issues, string labelName, StringBuilder builder)
{
var relevantIssues = issues
.Where(issue => issue.Labels.Any(label => label.Name == LabelPrefix + labelName))
.ToList();

if (relevantIssues.Any())
{
builder.AppendFormat(relevantIssues.Count == 1 ? "__{0}__\r\n" : "__{0}s__\r\n", labelName);

foreach (var issue in relevantIssues)
{
builder.AppendFormat("- [__#{0}__]({1}) {2}\r\n", issue.Number, issue.HtmlUrl, issue.Title);
}
static void PrintHeading(string labelName, StringBuilder builder)
{
builder.AppendFormat($"__{labelName}__\r\n");
}

builder.AppendLine();
static void PrintIssue(StringBuilder builder, List<Issue> relevantIssues)
{
foreach (var issue in relevantIssues)
{
builder.Append($"- [__#{issue.Number}__]({issue.HtmlUrl}) {issue.Title}\r\n");
}
}

Expand All @@ -145,7 +163,7 @@ void GetTargetMilestone()
targetMilestone = milestones.FirstOrDefault(x => x.Title == milestoneTitle);
if (targetMilestone == null)
{
throw new Exception(string.Format("Could not find milestone for '{0}'.", milestoneTitle));
throw new Exception($"Could not find milestone for '{milestoneTitle}'.");
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Tests/ReleaseNotesBuilderIntegrationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class ReleaseNotesBuilderIntegrationTests
[TestCase("NServiceBus", "5.1.0")]
[TestCase("ServiceControl", "1.0.0-Beta4")]
[TestCase("NServiceBus", "6.0.0")]
public async Task CoreVersion6(string repo, string version)
public async Task GenerateReleaseNotes(string repo, string version)
{
var gitHubClient = ClientBuilder.Build();

Expand Down