public async Task <string> BuildReleaseNotes() { await GetMilestones(); var stringBuilder = new StringBuilder(); GetTargetMilestone(); var commitsLink = GetCommitsLink(); stringBuilder.AppendFormat(@"This release consist of [these issues]({0}) that were achieved through [these commits]({1}).", targetMilestone.HtmlUrl(), commitsLink); stringBuilder.AppendLine(); stringBuilder.AppendLine(targetMilestone.Description); stringBuilder.AppendLine(); await AddIssues(stringBuilder); AddFooter(stringBuilder); var allText = stringBuilder.ToString(); using (var reader = new StringReader(allText)) { while (reader.Peek() >= 0) { var readLine = reader.ReadLine(); if (readLine != null && readLine.StartsWith("#######")) { throw new Exception("After the issue has been nested under the top level headings a line has resulted in a 'too deep' headin level. The resulting line is \r\n" + readLine); } } } return(allText); }
public async Task <string> BuildReleaseNotes() { LoadMilestones(); GetTargetMilestone(); var issues = await GetIssues(targetMilestone); var stringBuilder = new StringBuilder(); var previousMilestone = GetPreviousMilestone(); var numberOfCommits = await gitHubClient.GetNumberOfCommitsBetween(previousMilestone, targetMilestone); if (issues.Count > 0) { var issuesText = String.Format(issues.Count == 1 ? "{0} issue" : "{0} issues", issues.Count); if (numberOfCommits > 0) { var commitsLink = GetCommitsLink(previousMilestone); var commitsText = String.Format(numberOfCommits == 1 ? "{0} commit" : "{0} commits", numberOfCommits); stringBuilder.AppendFormat(@"As part of this release we had [{0}]({1}) which resulted in [{2}]({3}) being closed.", commitsText, commitsLink, issuesText, targetMilestone.HtmlUrl()); } else { stringBuilder.AppendFormat(@"As part of this release we had [{0}]({1}) closed.", issuesText, targetMilestone.HtmlUrl()); } } else if (numberOfCommits > 0) { var commitsLink = GetCommitsLink(previousMilestone); var commitsText = String.Format(numberOfCommits == 1 ? "{0} commit" : "{0} commits", numberOfCommits); stringBuilder.AppendFormat(@"As part of this release we had [{0}]({1}).", commitsText, commitsLink); } stringBuilder.AppendLine(); stringBuilder.AppendLine(targetMilestone.Description); stringBuilder.AppendLine(); AddIssues(stringBuilder, issues); await AddFooter(stringBuilder); return(stringBuilder.ToString()); }