diff options
Diffstat (limited to 'app/finders/merge_requests/oldest_per_commit_finder.rb')
-rw-r--r-- | app/finders/merge_requests/oldest_per_commit_finder.rb | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/app/finders/merge_requests/oldest_per_commit_finder.rb b/app/finders/merge_requests/oldest_per_commit_finder.rb index 5360f301036..5da7a08e36c 100644 --- a/app/finders/merge_requests/oldest_per_commit_finder.rb +++ b/app/finders/merge_requests/oldest_per_commit_finder.rb @@ -18,8 +18,8 @@ module MergeRequests mapping = {} shas = commits.map(&:id) - # To include merge requests by the commit SHA, we don't need to go through - # any diff rows. + # To include merge requests by the merge/squash SHA, we don't need to go + # through any diff rows. # # We can't squeeze all this into a single query, as the diff based data # relies on a GROUP BY. On the other hand, retrieving MRs by their merge @@ -27,12 +27,17 @@ module MergeRequests @project .merge_requests .preload_target_project - .by_merge_commit_sha(shas) + .by_merge_or_squash_commit_sha(shas) .each do |mr| - # Merge SHAs can't be in the merge request itself. It _is_ possible a - # newer merge request includes the merge commit, but in that case we - # still want the oldest merge request. - mapping[mr.merge_commit_sha] = mr + # Merge/squash SHAs can't be in the merge request itself. It _is_ + # possible a newer merge request includes the commit, but in that case + # we still want the oldest merge request. + # + # It's also possible that a merge request produces both a squashed + # commit and a merge commit. In that case we want to store the mapping + # for both the SHAs. + mapping[mr.squash_commit_sha] = mr if mr.squash_commit_sha + mapping[mr.merge_commit_sha] = mr if mr.merge_commit_sha end remaining = shas - mapping.keys |