summaryrefslogtreecommitdiff
path: root/app/models/commit.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/commit.rb')
-rw-r--r--app/models/commit.rb34
1 files changed, 12 insertions, 22 deletions
diff --git a/app/models/commit.rb b/app/models/commit.rb
index 1cabc060c2a..be5a118bfec 100644
--- a/app/models/commit.rb
+++ b/app/models/commit.rb
@@ -3,8 +3,12 @@ class Commit
include StaticModel
extend ActiveModel::Naming
include Mentionable
+ include Participable
attr_mentionable :safe_message
+ participant :author, :committer, :notes, :mentioned_users
+
+ attr_accessor :project
# Safe amount of changes (files and lines) in one commit to render
# Used to prevent 500 error on huge commits by suppressing diff
@@ -18,12 +22,12 @@ class Commit
DIFF_HARD_LIMIT_LINES = 50000 unless defined?(DIFF_HARD_LIMIT_LINES)
class << self
- def decorate(commits)
+ def decorate(commits, project)
commits.map do |commit|
if commit.kind_of?(Commit)
commit
else
- self.new(commit)
+ self.new(commit, project)
end
end
end
@@ -41,10 +45,11 @@ class Commit
attr_accessor :raw
- def initialize(raw_commit)
+ def initialize(raw_commit, project)
raise "Nil as raw commit passed" unless raw_commit
@raw = raw_commit
+ @project = project
end
def id
@@ -100,7 +105,7 @@ class Commit
description.present?
end
- def hook_attrs(project)
+ def hook_attrs
path_with_namespace = project.path_with_namespace
{
@@ -117,7 +122,7 @@ class Commit
# Discover issues should be closed when this commit is pushed to a project's
# default branch.
- def closes_issues(project, current_user = self.committer)
+ def closes_issues(current_user = self.committer)
Gitlab::ClosingIssueExtractor.new(project, current_user).closed_by_message(safe_message)
end
@@ -134,22 +139,7 @@ class Commit
User.find_for_commit(committer_email, committer_name)
end
- def participants(project, current_user = nil)
- users = []
- users << author
- users << committer
-
- users.push *self.mentioned_users(current_user, project)
-
- notes(project).each do |note|
- users << note.author
- users.push *note.mentioned_users(current_user, project)
- end
-
- users.uniq
- end
-
- def notes(project)
+ def notes
project.notes.for_commit_id(self.id)
end
@@ -169,6 +159,6 @@ class Commit
end
def parents
- @parents ||= Commit.decorate(super)
+ @parents ||= Commit.decorate(super, project)
end
end