This repository has been archived by the owner on Nov 27, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
changelog_template.erb
49 lines (39 loc) · 1.63 KB
/
changelog_template.erb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<%
labels_map = {}
labels_map['feature'] = 'Features'
labels_map['bug'] = 'Bugs'
labels_map['enhancement'] = 'Enhancement'
skip_release_notes_label = @labels.select {|label| label.name == "skip release notes" }.first
changelog_url_base = "https://github.com/#{@params[:github_project]}/compare/"
@releases.each do |release|
# Reject releases where label is not included in labels_map
data = release.data.reject {|label, prs| !labels_map[label.name]}
# Reject pull requests with 'Skip Release Notes' label
data.each do |label, prs|
prs.reject! {|pr| pr.label_ids.include?(skip_release_notes_label.id)} if skip_release_notes_label
end
# Reject labels with no pull requests
data = data.reject {|label, prs| prs.count == 0}
# Sort releases by label
sorted_data = {}
data.keys.sort_by {|label| labels_map.keys.index(label.name)}.each do |label|
sorted_data[label] = data[label]
end
# Update release with custom data
release.data = sorted_data
end
# Reject unreleased section if no data is available && is unreleased section
@releases.reject! {|release| release.data.count == 0 && release.to_tag.nil?}
-%>
<% for release in @releases -%>
## <%= release.display_title %>
<% if release.from_tag && release.to_tag -%>
[Full Changelog](<%= changelog_url_base + "#{release.from_tag}...#{release.to_tag}" %>)
<% end -%>
<% release.data.each do |label, pull_requests| -%>
**<%= labels_map[label.name] %>:**
<% for pr in pull_requests -%>
- <%= pr.title %> | [#<%= pr.number %>](<%= pr.html_url %>) | [@<%= pr.user.login %>](<%= pr.user.html_url %>)
<% end -%>
<% end -%>
<% end -%>