diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2013-01-05 00:49:58 +0200 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2013-01-05 00:49:58 +0200 |
commit | 0a94640e328ab30dcf90e65ba79242bc1aa77a57 (patch) | |
tree | 49599acd6e4dbc50de0491ff174588b1fbf0cf8e /app/models/commit.rb | |
parent | e6c0673ef1108a93928c4d88ba273e12616b836b (diff) | |
parent | de6fa5dd520244e9802b5b486ce9d437556baf31 (diff) | |
download | gitlab-ce-0a94640e328ab30dcf90e65ba79242bc1aa77a57.tar.gz |
Merge branch 'refactoring/backend'
Diffstat (limited to 'app/models/commit.rb')
-rw-r--r-- | app/models/commit.rb | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/app/models/commit.rb b/app/models/commit.rb index 07c5fbd7183..7e64c0f6e82 100644 --- a/app/models/commit.rb +++ b/app/models/commit.rb @@ -11,7 +11,7 @@ class Commit attr_accessor :commit, :head, :refs delegate :message, :authored_date, :committed_date, :parents, :sha, - :date, :committer, :author, :diffs, :tree, :id, + :date, :committer, :author, :diffs, :tree, :id, :stats, :to_patch, to: :commit class << self @@ -83,8 +83,8 @@ class Commit return result unless from && to - first = project.commit(to.try(:strip)) - last = project.commit(from.try(:strip)) + first = project.repository.commit(to.try(:strip)) + last = project.repository.commit(from.try(:strip)) if first && last result[:same] = (first.id == last.id) @@ -98,6 +98,8 @@ class Commit end def initialize(raw_commit, head = nil) + raise "Nil as raw commit passed" unless raw_commit + @commit = raw_commit @head = head end @@ -136,7 +138,11 @@ class Commit end def prev_commit - parents.try :first + @prev_commit ||= if parents.present? + Commit.new(parents.first) + else + nil + end end def prev_commit_id |