diff options
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/commit_collection.rb | 6 | ||||
-rw-r--r-- | app/models/merge_request.rb | 24 |
2 files changed, 23 insertions, 7 deletions
diff --git a/app/models/commit_collection.rb b/app/models/commit_collection.rb index e349f0fe971..885f61beb05 100644 --- a/app/models/commit_collection.rb +++ b/app/models/commit_collection.rb @@ -19,6 +19,12 @@ class CommitCollection commits.each(&block) end + def committers + emails = commits.reject(&:merge_commit?).map(&:committer_email).uniq + + User.by_any_email(emails) + end + # Sets the pipeline status for every commit. # # Setting this status ahead of time removes the need for running a query for diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb index 613860ec31a..5310f2ee765 100644 --- a/app/models/merge_request.rb +++ b/app/models/merge_request.rb @@ -284,6 +284,14 @@ class MergeRequest < ActiveRecord::Base work_in_progress?(title) ? title : "WIP: #{title}" end + def committers + @committers ||= commits.committers + end + + def authors + User.from_union([committers, User.where(id: self.author_id)]) + end + # Verifies if title has changed not taking into account WIP prefix # for merge requests. def wipless_title_changed(old_title) @@ -327,13 +335,15 @@ class MergeRequest < ActiveRecord::Base end def commits - if persisted? - merge_request_diff.commits - elsif compare_commits - compare_commits.reverse - else - [] - end + return merge_request_diff.commits if persisted? + + commits_arr = if compare_commits + compare_commits.reverse + else + [] + end + + CommitCollection.new(source_project, commits_arr, source_branch) end def commits_count |