Compare commits

...

1 Commits

View File

@ -1,5 +1,4 @@
# frozen_string_literal: true # frozen_string_literal: true
module GitHubChangelogGenerator module GitHubChangelogGenerator
class Generator class Generator
MAX_THREAD_NUMBER = 25 MAX_THREAD_NUMBER = 25
@ -49,18 +48,22 @@ module GitHubChangelogGenerator
end end
# Fill :actual_date parameter of specified issue by closed date of the commit, if it was closed by commit. # Fill :actual_date parameter of specified issue by closed date of the commit, if it was closed by commit.
# Or by merged_at, if that info exists.
# @param [Hash] issue # @param [Hash] issue
def find_closed_date_by_commit(issue) def find_closed_date_by_commit(issue)
unless issue["events"].nil? # in case of usual issue with no merge, find closed date.
# if it's PR -> then find "merged event", in case of usual issue -> fond closed date if issue["merged_at"].nil?
compare_string = issue["merged_at"].nil? ? "closed" : "merged" unless issue["events"].nil?
# reverse! - to find latest closed event. (event goes in date order) # reverse! - to find latest closed event. (event goes in date order)
issue["events"].reverse!.each do |event| issue["events"].reverse!.each do |event|
if event["event"].eql? compare_string if event["event"].eql? compare_string
set_date_from_event(event, issue) set_date_from_event(event, issue)
break break
end
end end
end end
else # if it's a PR, then go based on the merge event itself.
issue["actual_date"] = issue["merged_at"]
end end
# TODO: assert issues, that remain without 'actual_date' hash for some reason. # TODO: assert issues, that remain without 'actual_date' hash for some reason.
end end