diff options
author | Douwe Maan <douwe@gitlab.com> | 2015-04-21 16:09:15 +0300 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2015-04-24 13:29:36 +0300 |
commit | 84a1590252c63c710bceaa7a394799cdc5109505 (patch) | |
tree | 12d9b499acad48dc9420d095803705093d2b135d /app/models/commit.rb | |
parent | b0ed2ff1a69df384a1cb9a184c0528bec1986827 (diff) |
Let commit model know about its project.
Diffstat (limited to 'app/models/commit.rb')
-rw-r--r-- | app/models/commit.rb | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/app/models/commit.rb b/app/models/commit.rb index 1cabc060c2a..d4e9ebacac6 100644 --- a/app/models/commit.rb +++ b/app/models/commit.rb @@ -6,6 +6,8 @@ class Commit attr_mentionable :safe_message + 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 +20,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 +43,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 @@ -169,6 +172,6 @@ class Commit end def parents - @parents ||= Commit.decorate(super) + @parents ||= Commit.decorate(super, project) end end |