Skip to content

Commit

Permalink
Revert changes made to the default template and instead create a dist…
Browse files Browse the repository at this point in the history
…inct template called "contributors".
  • Loading branch information
Jericho committed Jul 14, 2024
1 parent 1c60283 commit 272bd03
Show file tree
Hide file tree
Showing 17 changed files with 105 additions and 52 deletions.
1 change: 1 addition & 0 deletions src/GitReleaseManager.Core/Configuration/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public Config()
ShaSectionHeading = "SHA256 Hashes of the release artifacts",
ShaSectionLineFormat = "- `{1}\t{0}`",
AllowUpdateToPublishedRelease = false,
IncludeContributors = true,
};

Export = new ExportConfig
Expand Down
3 changes: 3 additions & 0 deletions src/GitReleaseManager.Core/Configuration/CreateConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public async Task<string> BuildReleaseNotesAsync(string user, string repository,
issue.LinkedIssues = linkedIssues?.ToList().AsReadOnly() ?? Array.AsReadOnly(Array.Empty<Issue>());
}

var contributors = GetContributors(distinctValidIssues);
var contributors = _configuration.Create.IncludeContributors ? GetContributors(distinctValidIssues) : Enumerable.Empty<User>();

var milestoneQueryString = _vcsProvider.GetMilestoneQueryString();

Expand All @@ -88,7 +88,7 @@ public async Task<string> BuildReleaseNotesAsync(string user, string repository,
},
Contributors = new
{
Count = contributors.Count,
Count = contributors.Count(),
Items = contributors,
},
Commits = new
Expand Down
Original file line number Diff line number Diff line change
@@ -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 }}
13 changes: 13 additions & 0 deletions src/GitReleaseManager.Core/Templates/contributors/index.sbn
Original file line number Diff line number Diff line change
@@ -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
~}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

__{{ issue_label }}__
{{ for issue in issues.items[issue_label]
include 'issue-note'
end }}
45 changes: 45 additions & 0 deletions src/GitReleaseManager.Core/Templates/contributors/issue-note.sbn
Original file line number Diff line number Diff line change
@@ -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) }}
3 changes: 3 additions & 0 deletions src/GitReleaseManager.Core/Templates/contributors/issues.sbn
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{{ for issue_label in issue_labels
include 'issue-details'
end }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

{{ milestone.target.description }}
10 changes: 10 additions & 0 deletions src/GitReleaseManager.Core/Templates/contributors/release-info.sbn
Original file line number Diff line number Diff line change
@@ -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 -}}
3 changes: 0 additions & 3 deletions src/GitReleaseManager.Core/Templates/default/index.sbn
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

__{{ issue_label }}__

{{ for issue in issues.items[issue_label]
include 'issue-note'
end }}
49 changes: 5 additions & 44 deletions src/GitReleaseManager.Core/Templates/default/issue-note.sbn
Original file line number Diff line number Diff line change
@@ -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) }}
if issue.is_pull_request
}}- [__!{{ issue.public_number }}__]({{ issue.html_url }}) {{ issue.title }}
{{ else
}}- [__#{{ issue.public_number }}__]({{ issue.html_url }}) {{ issue.title }}
{{ end -}}
3 changes: 2 additions & 1 deletion src/GitReleaseManager.Core/Templates/default/issues.sbn
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

{{ for issue_label in issue_labels
include 'issue-details'
end }}
end }}
4 changes: 3 additions & 1 deletion src/GitReleaseManager.Core/VcsService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ public async Task<Release> CreateEmptyReleaseAsync(string owner, string reposito

public async Task<Release> CreateReleaseFromMilestoneAsync(string owner, string repository, string milestone, string releaseName, string targetCommitish, IList<string> 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))
{
Expand Down

0 comments on commit 272bd03

Please sign in to comment.