Skip to content

When we have merged_at info, just use that, because a PR's merge event commit date seems to merely be the date of the last commit, which is often very different than the date the PR was merged. #620

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions lib/github_changelog_generator/generator/generator_fetcher.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# frozen_string_literal: true

module GitHubChangelogGenerator
class Generator
MAX_THREAD_NUMBER = 25
Expand Down Expand Up @@ -49,18 +48,22 @@ def detect_actual_closed_dates(issues)
end

# 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
def find_closed_date_by_commit(issue)
unless issue["events"].nil?
# if it's PR -> then find "merged event", in case of usual issue -> fond closed date
compare_string = issue["merged_at"].nil? ? "closed" : "merged"
# reverse! - to find latest closed event. (event goes in date order)
issue["events"].reverse!.each do |event|
if event["event"].eql? compare_string
set_date_from_event(event, issue)
break
# in case of usual issue with no merge, find closed date.
if issue["merged_at"].nil?
unless issue["events"].nil?
# reverse! - to find latest closed event. (event goes in date order)
issue["events"].reverse!.each do |event|
if event["event"].eql? compare_string
set_date_from_event(event, issue)
break
end
end
end
else # if it's a PR, then go based on the merge event itself.
issue["actual_date"] = issue["merged_at"]
end
# TODO: assert issues, that remain without 'actual_date' hash for some reason.
end
Expand Down