github_changelog_generator 1.17.0 → 1.18.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/github_changelog_generator/generator/entry.rb +5 -3
- data/lib/github_changelog_generator/generator/generator_fetcher.rb +38 -25
- data/lib/github_changelog_generator/generator/generator_processor.rb +1 -1
- data/lib/github_changelog_generator/generator/generator_tags.rb +1 -1
- data/lib/github_changelog_generator/octo_fetcher.rb +25 -13
- data/lib/github_changelog_generator/ssl_certs/cacert.pem +1291 -1570
- data/lib/github_changelog_generator/version.rb +1 -1
- data/spec/unit/generator/generator_spec.rb +11 -0
- data/spec/unit/octo_fetcher_spec.rb +36 -0
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 02c70cf1019c3603b290a41cc84ec82077593e8d469c962ab5fa4fe734fba333
|
|
4
|
+
data.tar.gz: 9ffd88608d0ab0fe21dd2a8f2d0da2d5129acd8a7c34f306d518a1e06a6d42d7
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3f6980de2561fb771959cb5105bb496086ad06cc99a154e4b5aa433000919870c9c61e76803394c19a5fdd7c508007f945a09ed44d5e6a50d476c5daa434e328
|
|
7
|
+
data.tar.gz: 7fe4fd627c90f0be974e78491c2f99079ee5998365dc8d3249f340e7e5194b35db550ca399acdd2c26d238ef4d0d795a6c9ad079796f203a80882d73f12d1310
|
|
@@ -17,7 +17,7 @@ module GitHubChangelogGenerator
|
|
|
17
17
|
|
|
18
18
|
def initialize(options = Options.new({}))
|
|
19
19
|
@content = ""
|
|
20
|
-
@options = Options.new(options)
|
|
20
|
+
@options = options.is_a?(Options) ? options : Options.new(options)
|
|
21
21
|
end
|
|
22
22
|
|
|
23
23
|
# Generates log entry with header and body
|
|
@@ -209,8 +209,10 @@ module GitHubChangelogGenerator
|
|
|
209
209
|
# Only add unmapped issues
|
|
210
210
|
issues.select { |issue| issue["labels"].any? }
|
|
211
211
|
end
|
|
212
|
-
|
|
213
|
-
|
|
212
|
+
unless add_issues.empty?
|
|
213
|
+
merged = Section.new(name: name, prefix: prefix, labels: [], issues: add_issues, options: @options)
|
|
214
|
+
@sections << merged
|
|
215
|
+
end
|
|
214
216
|
end
|
|
215
217
|
nil
|
|
216
218
|
end
|
|
@@ -81,17 +81,22 @@ module GitHubChangelogGenerator
|
|
|
81
81
|
else
|
|
82
82
|
# Either there were no events or no merged event. GitHub's api can be
|
|
83
83
|
# weird like that apparently. Check for a rebased comment before erroring.
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
found = true
|
|
88
|
-
i += 1
|
|
89
|
-
print("Associating PRs with tags: #{i}/#{total}\r") if @options[:verbose]
|
|
84
|
+
found = associate_pr_without_merge_event(tags, pr, total)
|
|
85
|
+
i += 1 if found
|
|
90
86
|
end
|
|
91
87
|
found
|
|
92
88
|
end
|
|
93
89
|
end
|
|
94
90
|
|
|
91
|
+
def associate_pr_without_merge_event(tags, pull_request, total)
|
|
92
|
+
unassociated = associate_rebase_comment_prs(tags, [pull_request], total)
|
|
93
|
+
return false if pull_request["comments_incomplete"]
|
|
94
|
+
|
|
95
|
+
raise StandardError, "No merge sha found for PR #{pull_request['number']} via the GitHub API" unless unassociated.empty?
|
|
96
|
+
|
|
97
|
+
true
|
|
98
|
+
end
|
|
99
|
+
|
|
95
100
|
# Associate merged PRs by the HEAD of the release branch. If no
|
|
96
101
|
# --release-branch was specified, then the github default branch is used.
|
|
97
102
|
#
|
|
@@ -127,29 +132,37 @@ module GitHubChangelogGenerator
|
|
|
127
132
|
# Any remaining PRs were not found in the list of tags by their merge
|
|
128
133
|
# commit and not found in any specified release branch. Fallback to
|
|
129
134
|
# rebased commit comment.
|
|
130
|
-
|
|
135
|
+
pending = prs_left.reject { |pr| pr["comments_incomplete"] }
|
|
136
|
+
@fetcher.fetch_comments_async(pending) unless pending.empty?
|
|
131
137
|
prs_left.reject do |pr|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
elsif sha_in_release_branch?(rebased_sha)
|
|
140
|
-
found = true
|
|
141
|
-
i += 1
|
|
142
|
-
else
|
|
143
|
-
raise StandardError, "PR #{pr['number']} has a rebased SHA comment but that SHA was not found in the release branch or any tags"
|
|
144
|
-
end
|
|
145
|
-
print("Associating PRs with tags: #{i}/#{total}\r") if @options[:verbose]
|
|
146
|
-
else
|
|
147
|
-
puts "Warning: PR #{pr['number']} merge commit was not found in the release branch or tagged git history and no rebased SHA comment was found"
|
|
148
|
-
end
|
|
149
|
-
found
|
|
138
|
+
next false if pr["comments_incomplete"]
|
|
139
|
+
|
|
140
|
+
next false unless associate_rebased_pr(tags, pr)
|
|
141
|
+
|
|
142
|
+
i += 1
|
|
143
|
+
print("Associating PRs with tags: #{i}/#{total}\r") if @options[:verbose]
|
|
144
|
+
true
|
|
150
145
|
end
|
|
151
146
|
end
|
|
152
147
|
|
|
148
|
+
def associate_rebased_pr(tags, pull_request)
|
|
149
|
+
rebased_sha = (pull_request["comments"] || []).reverse_each.lazy.filter_map do |comment|
|
|
150
|
+
comment["body"][/rebased commit: ([0-9a-f]{40})/i, 1]
|
|
151
|
+
end.first
|
|
152
|
+
unless rebased_sha
|
|
153
|
+
puts "Warning: PR #{pull_request['number']} merge commit was not found in the release branch or tagged git history and no rebased SHA comment was found"
|
|
154
|
+
return false
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
if (oldest_tag = tags.reverse.find { |tag| tag["shas_in_tag"].include?(rebased_sha) })
|
|
158
|
+
pull_request["first_occurring_tag"] = oldest_tag["name"]
|
|
159
|
+
return true
|
|
160
|
+
end
|
|
161
|
+
return true if sha_in_release_branch?(rebased_sha)
|
|
162
|
+
|
|
163
|
+
raise StandardError, "PR #{pull_request['number']} has a rebased SHA comment but that SHA was not found in the release branch or any tags"
|
|
164
|
+
end
|
|
165
|
+
|
|
153
166
|
# Fill :actual_date parameter of specified issue by closed date of the commit, if it was closed by commit.
|
|
154
167
|
# @param [Hash] issue
|
|
155
168
|
def find_closed_date_by_commit(issue)
|
|
@@ -23,7 +23,7 @@ module GitHubChangelogGenerator
|
|
|
23
23
|
# @param [Array] filtered_tags is the list of filtered tags ordered from newest -> oldest
|
|
24
24
|
# @return [Hash] key is the tag to output, value is an array of [Left Tag, Right Tag]
|
|
25
25
|
# PRs to include in this section will be >= [Left Tag Date] and <= [Right Tag Date]
|
|
26
|
-
# rubocop:disable Style/For
|
|
26
|
+
# rubocop:disable Style/For -- for allows us to be more concise
|
|
27
27
|
def build_tag_section_mapping(section_tags, filtered_tags)
|
|
28
28
|
tag_mapping = {}
|
|
29
29
|
for i in 0..(section_tags.length - 1)
|
|
@@ -208,7 +208,8 @@ Make sure, that you push tags to remote repo via 'git push --tags'"
|
|
|
208
208
|
# @param [Array] issues
|
|
209
209
|
# @return [Void]
|
|
210
210
|
def fetch_events_async(issues)
|
|
211
|
-
|
|
211
|
+
fetched_count = 0
|
|
212
|
+
mutex = Mutex.new
|
|
212
213
|
# Add accept option explicitly for disabling the warning of preview API.
|
|
213
214
|
preview = { accept: Octokit::Preview::PREVIEW_TYPES[:project_card_events] }
|
|
214
215
|
|
|
@@ -225,8 +226,8 @@ Make sure, that you push tags to remote repo via 'git push --tags'"
|
|
|
225
226
|
issue["events"].concat(new_event)
|
|
226
227
|
end
|
|
227
228
|
issue["events"] = issue["events"].map { |event| stringify_keys_deep(event.to_hash) }
|
|
228
|
-
|
|
229
|
-
|
|
229
|
+
current = mutex.synchronize { fetched_count += 1 }
|
|
230
|
+
print_in_same_line("Fetching events for issues and PR: #{current}/#{issues.count}")
|
|
230
231
|
end
|
|
231
232
|
end
|
|
232
233
|
|
|
@@ -236,7 +237,7 @@ Make sure, that you push tags to remote repo via 'git push --tags'"
|
|
|
236
237
|
print_empty_line
|
|
237
238
|
end
|
|
238
239
|
|
|
239
|
-
Helper.log.info "Fetching events for issues and PR: #{
|
|
240
|
+
Helper.log.info "Fetching events for issues and PR: #{fetched_count}"
|
|
240
241
|
end
|
|
241
242
|
|
|
242
243
|
# Fetch comments for PRs and add them to "comments"
|
|
@@ -252,11 +253,22 @@ Make sure, that you push tags to remote repo via 'git push --tags'"
|
|
|
252
253
|
|
|
253
254
|
prs.each do |pr|
|
|
254
255
|
semaphore.async do
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
256
|
+
comments = []
|
|
257
|
+
missing_page = false
|
|
258
|
+
iterate_pages(client, "issue_comments", pr["number"]) do |page|
|
|
259
|
+
if page.nil?
|
|
260
|
+
missing_page = true
|
|
261
|
+
else
|
|
262
|
+
comments.concat(page)
|
|
263
|
+
end
|
|
258
264
|
end
|
|
259
|
-
|
|
265
|
+
|
|
266
|
+
if missing_page
|
|
267
|
+
Helper.log.warn "Omitting PR ##{pr['number']} from the changelog because GitHub returned incomplete comments needed to identify its release"
|
|
268
|
+
comments.clear
|
|
269
|
+
end
|
|
270
|
+
pr["comments_incomplete"] = missing_page
|
|
271
|
+
pr["comments"] = comments.map { |comment| stringify_keys_deep(comment.to_hash) }
|
|
260
272
|
end
|
|
261
273
|
end
|
|
262
274
|
|
|
@@ -345,13 +357,13 @@ Make sure, that you push tags to remote repo via 'git push --tags'"
|
|
|
345
357
|
# @param [String] name
|
|
346
358
|
# @return [Array<String>]
|
|
347
359
|
def commits_in_branch(name)
|
|
348
|
-
@branches ||=
|
|
360
|
+
@branches ||= begin
|
|
361
|
+
all_branches = {}
|
|
349
362
|
iterate_pages(client, "branches") do |branches|
|
|
350
|
-
|
|
351
|
-
return branches_map if branches_map[name]
|
|
363
|
+
branches.each { |branch| all_branches[branch[:name]] = branch }
|
|
352
364
|
end
|
|
353
|
-
|
|
354
|
-
end
|
|
365
|
+
all_branches
|
|
366
|
+
end
|
|
355
367
|
|
|
356
368
|
if (branch = @branches[name])
|
|
357
369
|
commits_in_tag(branch[:commit][:sha])
|