diff options
| author | Timothy Andrew <mail@timothyandrew.net> | 2016-06-03 09:31:16 +0530 |
|---|---|---|
| committer | Timothy Andrew <mail@timothyandrew.net> | 2016-06-03 09:31:16 +0530 |
| commit | ae0d8222afe1c2482765c92240d35f41d54a73db (patch) | |
| tree | f3ef7e7fd87f21bae33a595d848c18fd56df8b75 /app/models/commit.rb | |
| parent | ffe111c1e22b0cce827c297fea62dfb0bd91326a (diff) | |
| parent | 07b46517cc940b429515374e4e102ff04405e804 (diff) | |
| download | gitlab-ce-ae0d8222afe1c2482765c92240d35f41d54a73db.tar.gz | |
Merge remote-tracking branch 'origin/master' into 2979-personal-access-tokens
Diffstat (limited to 'app/models/commit.rb')
| -rw-r--r-- | app/models/commit.rb | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/app/models/commit.rb b/app/models/commit.rb index 562c3ed15b2..f96c7cb34d0 100644 --- a/app/models/commit.rb +++ b/app/models/commit.rb @@ -8,7 +8,10 @@ class Commit include StaticModel attr_mentionable :safe_message, pipeline: :single_line - participant :author, :committer, :notes + + participant :author + participant :committer + participant :notes_with_associations attr_accessor :project @@ -194,6 +197,10 @@ class Commit project.notes.for_commit_id(self.id) end + def notes_with_associations + notes.includes(:author, :project) + end + def method_missing(m, *args, &block) @raw.send(m, *args, &block) end @@ -219,7 +226,7 @@ class Commit def revert_branch_name "revert-#{short_id}" end - + def cherry_pick_branch_name project.repository.next_branch("cherry-pick-#{short_id}", mild: true) end @@ -251,11 +258,13 @@ class Commit end def has_been_reverted?(current_user = nil, noteable = self) - Gitlab::ReferenceExtractor.lazily do - noteable.notes.system.flat_map do |note| - note.all_references(current_user).commits - end - end.any? { |commit_ref| commit_ref.reverts_commit?(self) } + ext = all_references(current_user) + + noteable.notes_with_associations.system.each do |note| + note.all_references(current_user, extractor: ext) + end + + ext.commits.any? { |commit_ref| commit_ref.reverts_commit?(self) } end def change_type_title |
