diff --git a/src/GitReleaseManager.Core/Configuration/Config.cs b/src/GitReleaseManager.Core/Configuration/Config.cs index 15083cc2..eee6d8ce 100644 --- a/src/GitReleaseManager.Core/Configuration/Config.cs +++ b/src/GitReleaseManager.Core/Configuration/Config.cs @@ -27,6 +27,7 @@ public Config() ShaSectionHeading = "SHA256 Hashes of the release artifacts", ShaSectionLineFormat = "- `{1}\t{0}`", AllowUpdateToPublishedRelease = false, + IncludeContributors = true, }; Export = new ExportConfig diff --git a/src/GitReleaseManager.Core/Configuration/CreateConfig.cs b/src/GitReleaseManager.Core/Configuration/CreateConfig.cs index 512e4a28..00baed7d 100644 --- a/src/GitReleaseManager.Core/Configuration/CreateConfig.cs +++ b/src/GitReleaseManager.Core/Configuration/CreateConfig.cs @@ -34,5 +34,8 @@ public class CreateConfig [YamlMember(Alias = "allow-update-to-published")] public bool AllowUpdateToPublishedRelease { get; set; } + + [YamlMember(Alias = "include-contributors")] + public bool IncludeContributors { get; set; } } } \ No newline at end of file diff --git a/src/GitReleaseManager.Core/ReleaseNotes/ReleaseNotesBuilder.cs b/src/GitReleaseManager.Core/ReleaseNotes/ReleaseNotesBuilder.cs index f9a220ec..304af73a 100644 --- a/src/GitReleaseManager.Core/ReleaseNotes/ReleaseNotesBuilder.cs +++ b/src/GitReleaseManager.Core/ReleaseNotes/ReleaseNotesBuilder.cs @@ -75,7 +75,7 @@ public async Task BuildReleaseNotesAsync(string user, string repository, issue.LinkedIssues = linkedIssues?.ToList().AsReadOnly() ?? Array.AsReadOnly(Array.Empty()); } - var contributors = GetContributors(distinctValidIssues); + var contributors = _configuration.Create.IncludeContributors ? GetContributors(distinctValidIssues) : Enumerable.Empty(); var milestoneQueryString = _vcsProvider.GetMilestoneQueryString(); @@ -88,7 +88,7 @@ public async Task BuildReleaseNotesAsync(string user, string repository, }, Contributors = new { - Count = contributors.Count, + Count = contributors.Count(), Items = contributors, }, Commits = new diff --git a/src/GitReleaseManager.Core/Templates/default/contributor-details.sbn b/src/GitReleaseManager.Core/Templates/contributors/contributor-details.sbn similarity index 100% rename from src/GitReleaseManager.Core/Templates/default/contributor-details.sbn rename to src/GitReleaseManager.Core/Templates/contributors/contributor-details.sbn diff --git a/src/GitReleaseManager.Core/Templates/default/contributors.sbn b/src/GitReleaseManager.Core/Templates/contributors/contributors.sbn similarity index 100% rename from src/GitReleaseManager.Core/Templates/default/contributors.sbn rename to src/GitReleaseManager.Core/Templates/contributors/contributors.sbn diff --git a/src/GitReleaseManager.Core/Templates/contributors/create/footer.sbn b/src/GitReleaseManager.Core/Templates/contributors/create/footer.sbn new file mode 100644 index 00000000..b1b08303 --- /dev/null +++ b/src/GitReleaseManager.Core/Templates/contributors/create/footer.sbn @@ -0,0 +1,10 @@ +{{ if config.create.include_footer }} + +### {{ config.create.footer_heading }} + +{{ if config.create.milestone_replace_text + replace_milestone_title config.create.footer_content config.create.milestone_replace_text milestone.target.title + else + config.create.footer_content + end +end }} diff --git a/src/GitReleaseManager.Core/Templates/contributors/index.sbn b/src/GitReleaseManager.Core/Templates/contributors/index.sbn new file mode 100644 index 00000000..fe306967 --- /dev/null +++ b/src/GitReleaseManager.Core/Templates/contributors/index.sbn @@ -0,0 +1,13 @@ +{{- + include 'release-info' + if milestone.target.description + include 'milestone' + end + include 'issues' | string.rstrip + if contributors.count > 0 + include 'contributors' + end + if template_kind == "CREATE" + include 'create/footer' + end +~}} diff --git a/src/GitReleaseManager.Core/Templates/contributors/issue-details.sbn b/src/GitReleaseManager.Core/Templates/contributors/issue-details.sbn new file mode 100644 index 00000000..70183381 --- /dev/null +++ b/src/GitReleaseManager.Core/Templates/contributors/issue-details.sbn @@ -0,0 +1,5 @@ + +__{{ issue_label }}__ +{{ for issue in issues.items[issue_label] + include 'issue-note' +end }} diff --git a/src/GitReleaseManager.Core/Templates/contributors/issue-note.sbn b/src/GitReleaseManager.Core/Templates/contributors/issue-note.sbn new file mode 100644 index 00000000..ac7a11a1 --- /dev/null +++ b/src/GitReleaseManager.Core/Templates/contributors/issue-note.sbn @@ -0,0 +1,45 @@ +{{ +func IssueDescription + if $0.is_pull_request + $description = "[__!" + $0.public_number + "__]" + else + $description = "[__#" + $0.public_number + "__]" + end + $description = $description + "(" + $0.html_url + ")" + if $1 + $description = $description + " " + $0.title + end + if $0.user + $description = $description + " by [" + $0.user.login + "](" + $0.user.html_url + ")" + end + if $0.linked_issues + $description = $description + LinkedIssuesDescription($0.linked_issues) + end + ret $description +end +func LinkedIssuesDescription + $countPRs = 0 + $countIssues = 0 + for linkedIssue in $0 + if linkedIssue.is_pull_request + if $countPRs == 0 + $resolvedBy = " resolved in " + else + $resolvedBy = $resolvedBy + ", " + end + $resolvedBy = $resolvedBy + IssueDescription(linkedIssue, false) + $countPRs = $countPRs + 1 + else + if $countIssues == 0 + $raisedIn = " raised in " + else + $raisedIn = $raisedIn + ", " + end + $raisedIn = $raisedIn + IssueDescription(linkedIssue, false) + $countIssues = $countIssues + 1 + end + end + ret $raisedIn + $resolvedBy +end +}} +- {{ IssueDescription(issue, true) }} \ No newline at end of file diff --git a/src/GitReleaseManager.Core/Templates/contributors/issues.sbn b/src/GitReleaseManager.Core/Templates/contributors/issues.sbn new file mode 100644 index 00000000..d8f323f4 --- /dev/null +++ b/src/GitReleaseManager.Core/Templates/contributors/issues.sbn @@ -0,0 +1,3 @@ +{{ for issue_label in issue_labels + include 'issue-details' +end }} \ No newline at end of file diff --git a/src/GitReleaseManager.Core/Templates/contributors/milestone.sbn b/src/GitReleaseManager.Core/Templates/contributors/milestone.sbn new file mode 100644 index 00000000..b3459681 --- /dev/null +++ b/src/GitReleaseManager.Core/Templates/contributors/milestone.sbn @@ -0,0 +1,2 @@ + +{{ milestone.target.description }} diff --git a/src/GitReleaseManager.Core/Templates/contributors/release-info.sbn b/src/GitReleaseManager.Core/Templates/contributors/release-info.sbn new file mode 100644 index 00000000..c8f7e8e2 --- /dev/null +++ b/src/GitReleaseManager.Core/Templates/contributors/release-info.sbn @@ -0,0 +1,10 @@ +{{ + if issues.count > 0 + if commits.count > 0 +}}As part of this release we had [{{ commits.count }} {{ commits.count | string.pluralize "commit" "commits" }}]({{ commits.html_url }}) which resulted in [{{ issues.count }} {{ issues.count | string.pluralize "issue" "issues" }}]({{ milestone.target.html_url }}?{{ milestone.query_string }}) being closed. +{{ else +}}As part of this release we had [{{ issues.count }} {{ issues.count | string.pluralize "issue" "issues" }}]({{ milestone.target.html_url }}?{{ milestone.query_string }}) closed. +{{ end + else if commits.count > 0 +}}As part of this release we had [{{ commits.count }} {{ commits.count | string.pluralize "commit" "commits" }}]({{ commits.html_url }}). +{{ end -}} diff --git a/src/GitReleaseManager.Core/Templates/default/index.sbn b/src/GitReleaseManager.Core/Templates/default/index.sbn index fe306967..1a3856e2 100644 --- a/src/GitReleaseManager.Core/Templates/default/index.sbn +++ b/src/GitReleaseManager.Core/Templates/default/index.sbn @@ -4,9 +4,6 @@ include 'milestone' end include 'issues' | string.rstrip - if contributors.count > 0 - include 'contributors' - end if template_kind == "CREATE" include 'create/footer' end diff --git a/src/GitReleaseManager.Core/Templates/default/issue-details.sbn b/src/GitReleaseManager.Core/Templates/default/issue-details.sbn index 70183381..8e049a29 100644 --- a/src/GitReleaseManager.Core/Templates/default/issue-details.sbn +++ b/src/GitReleaseManager.Core/Templates/default/issue-details.sbn @@ -1,5 +1,5 @@ - __{{ issue_label }}__ + {{ for issue in issues.items[issue_label] include 'issue-note' end }} diff --git a/src/GitReleaseManager.Core/Templates/default/issue-note.sbn b/src/GitReleaseManager.Core/Templates/default/issue-note.sbn index ac7a11a1..218ae3cb 100644 --- a/src/GitReleaseManager.Core/Templates/default/issue-note.sbn +++ b/src/GitReleaseManager.Core/Templates/default/issue-note.sbn @@ -1,45 +1,6 @@ {{ -func IssueDescription - if $0.is_pull_request - $description = "[__!" + $0.public_number + "__]" - else - $description = "[__#" + $0.public_number + "__]" - end - $description = $description + "(" + $0.html_url + ")" - if $1 - $description = $description + " " + $0.title - end - if $0.user - $description = $description + " by [" + $0.user.login + "](" + $0.user.html_url + ")" - end - if $0.linked_issues - $description = $description + LinkedIssuesDescription($0.linked_issues) - end - ret $description -end -func LinkedIssuesDescription - $countPRs = 0 - $countIssues = 0 - for linkedIssue in $0 - if linkedIssue.is_pull_request - if $countPRs == 0 - $resolvedBy = " resolved in " - else - $resolvedBy = $resolvedBy + ", " - end - $resolvedBy = $resolvedBy + IssueDescription(linkedIssue, false) - $countPRs = $countPRs + 1 - else - if $countIssues == 0 - $raisedIn = " raised in " - else - $raisedIn = $raisedIn + ", " - end - $raisedIn = $raisedIn + IssueDescription(linkedIssue, false) - $countIssues = $countIssues + 1 - end - end - ret $raisedIn + $resolvedBy -end -}} -- {{ IssueDescription(issue, true) }} \ No newline at end of file + if issue.is_pull_request +}}- [__!{{ issue.public_number }}__]({{ issue.html_url }}) {{ issue.title }} +{{ else +}}- [__#{{ issue.public_number }}__]({{ issue.html_url }}) {{ issue.title }} +{{ end -}} diff --git a/src/GitReleaseManager.Core/Templates/default/issues.sbn b/src/GitReleaseManager.Core/Templates/default/issues.sbn index d8f323f4..307b6080 100644 --- a/src/GitReleaseManager.Core/Templates/default/issues.sbn +++ b/src/GitReleaseManager.Core/Templates/default/issues.sbn @@ -1,3 +1,4 @@ + {{ for issue_label in issue_labels include 'issue-details' -end }} \ No newline at end of file +end }} diff --git a/src/GitReleaseManager.Core/VcsService.cs b/src/GitReleaseManager.Core/VcsService.cs index 601a20b3..6f972a4c 100644 --- a/src/GitReleaseManager.Core/VcsService.cs +++ b/src/GitReleaseManager.Core/VcsService.cs @@ -46,7 +46,9 @@ public async Task CreateEmptyReleaseAsync(string owner, string reposito public async Task CreateReleaseFromMilestoneAsync(string owner, string repository, string milestone, string releaseName, string targetCommitish, IList assets, bool prerelease, string templateFilePath) { - var templatePath = ReleaseTemplates.DEFAULT_NAME; + var templatePath = _configuration.Create.IncludeContributors + ? ReleaseTemplates.CONTRIBUTORS_NAME + : ReleaseTemplates.DEFAULT_NAME; if (!string.IsNullOrWhiteSpace(templateFilePath)) {