From e16cebac3eaadc0df93576358f60ae4a498ce15f Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Sat, 5 Jan 2013 00:35:38 +0200 Subject: Fixed styles, ProjectHook specs etc --- app/models/commit.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'app/models/commit.rb') diff --git a/app/models/commit.rb b/app/models/commit.rb index a1d89600126..7e64c0f6e82 100644 --- a/app/models/commit.rb +++ b/app/models/commit.rb @@ -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 -- cgit v1.2.1