summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorDouwe Maan <douwe@selenight.nl>2016-01-28 15:10:48 +0100
committerDouwe Maan <douwe@selenight.nl>2016-01-28 15:10:48 +0100
commit30b0d06e9f74f0068926314ec03b003fbd86c8f2 (patch)
treea6483ff763e13a493dbd6a64200678e9dc7094b4 /app
parent5cce1278adb168cd9fa4f189e3656a59726b4e6c (diff)
downloadgitlab-ce-30b0d06e9f74f0068926314ec03b003fbd86c8f2.tar.gz
Fix specs
Diffstat (limited to 'app')
-rw-r--r--app/models/merge_request.rb4
-rw-r--r--app/models/project.rb3
-rw-r--r--app/models/repository.rb2
3 files changed, 6 insertions, 3 deletions
diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb
index 85dce768cf3..0af60645545 100644
--- a/app/models/merge_request.rb
+++ b/app/models/merge_request.rb
@@ -183,7 +183,7 @@ class MergeRequest < ActiveRecord::Base
def diff_base_commit
if merge_request_diff
merge_request_diff.base_commit
- else
+ elsif source_sha
self.target_project.merge_base_commit(self.source_sha, self.target_branch)
end
end
@@ -489,7 +489,7 @@ class MergeRequest < ActiveRecord::Base
end
def source_sha
- last_commit.sha
+ last_commit.try(:sha)
end
def fetch_ref
diff --git a/app/models/project.rb b/app/models/project.rb
index 488dc98c17f..238932f59a7 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -349,7 +349,8 @@ class Project < ActiveRecord::Base
end
def merge_base_commit(first_commit_id, second_commit_id)
- repository.commit(repository.merge_base(first_commit_id, second_commit_id))
+ sha = repository.merge_base(first_commit_id, second_commit_id)
+ repository.commit(sha) if sha
end
def saved?
diff --git a/app/models/repository.rb b/app/models/repository.rb
index 6c1ee4b29cd..130daddd9d1 100644
--- a/app/models/repository.rb
+++ b/app/models/repository.rb
@@ -589,6 +589,8 @@ class Repository
def merge_base(first_commit_id, second_commit_id)
rugged.merge_base(first_commit_id, second_commit_id)
+ rescue Rugged::ReferenceError
+ nil
end
def is_ancestor?(ancestor_id, descendant_id)