diff options
Diffstat (limited to 'app/finders/merge_requests')
-rw-r--r-- | app/finders/merge_requests/by_approvals_finder.rb | 8 | ||||
-rw-r--r-- | app/finders/merge_requests/oldest_per_commit_finder.rb | 19 |
2 files changed, 16 insertions, 11 deletions
diff --git a/app/finders/merge_requests/by_approvals_finder.rb b/app/finders/merge_requests/by_approvals_finder.rb index e6ab1467f06..94f13468327 100644 --- a/app/finders/merge_requests/by_approvals_finder.rb +++ b/app/finders/merge_requests/by_approvals_finder.rb @@ -60,14 +60,14 @@ module MergeRequests ids.first.to_s.downcase == label || usernames.map(&:downcase).include?(label) end - # Merge Requests without any approval + # Merge requests without any approval # # @param [ActiveRecord::Relation] items def without_approvals(items) items.without_approvals end - # Merge Requests with any number of approvals + # Merge requests with any number of approvals # # @param [ActiveRecord::Relation] items the activerecord relation def with_any_approvals(items) @@ -76,14 +76,14 @@ module MergeRequests ]) end - # Merge Requests approved by given usernames + # Merge requests approved by given usernames # # @param [ActiveRecord::Relation] items the activerecord relation def find_approved_by_names(items) items.approved_by_users_with_usernames(*usernames) end - # Merge Requests approved by given user IDs + # Merge requests approved by given user IDs # # @param [ActiveRecord::Relation] items the activerecord relation def find_approved_by_ids(items) 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 |