summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2013-01-05 00:35:38 +0200
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2013-01-05 00:35:38 +0200
commite16cebac3eaadc0df93576358f60ae4a498ce15f (patch)
tree986cf1f20647bf98808e8a14b0faf3c93d368463 /app/models
parentc6298678f5032823130f5b2eb6fc1810cbb01a10 (diff)
downloadgitlab-ce-e16cebac3eaadc0df93576358f60ae4a498ce15f.tar.gz
Fixed styles, ProjectHook specs etc
Diffstat (limited to 'app/models')
-rw-r--r--app/models/commit.rb8
-rw-r--r--app/models/project.rb4
2 files changed, 9 insertions, 3 deletions
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
diff --git a/app/models/project.rb b/app/models/project.rb
index 850653988c9..2204d4a56e5 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -361,8 +361,8 @@ class Project < ActiveRecord::Base
# Discover the default branch, but only if it hasn't already been set to
# something else
- if default_branch.nil?
- update_attributes(default_branch: discover_default_branch)
+ if repository && default_branch.nil?
+ update_attributes(default_branch: self.repository.discover_default_branch)
end
end