diff options
author | Tiago Botelho <tiagonbotelho@hotmail.com> | 2019-01-03 10:59:14 +0000 |
---|---|---|
committer | Douwe Maan <douwe@selenight.nl> | 2019-01-08 00:27:29 +0100 |
commit | a2842241d4f583625053aba4d2c37a2f15b21913 (patch) | |
tree | 088aeb8c89c56e20ea5f003e3556584b5b524232 /app/models/merge_request.rb | |
parent | cfa7108210490704a8110ee97a26de9ae4d9adaf (diff) | |
download | gitlab-ce-a2842241d4f583625053aba4d2c37a2f15b21913.tar.gz |
Add committers and authors methods on MergeRequest
These are used by the EE-only approvers feature
Diffstat (limited to 'app/models/merge_request.rb')
-rw-r--r-- | app/models/merge_request.rb | 24 |
1 files changed, 17 insertions, 7 deletions
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 |