From de8497ca56a20f8c9362fdb8a9a8629a551f0a4d Mon Sep 17 00:00:00 2001 From: Stan Hu Date: Fri, 18 Sep 2015 12:02:01 -0700 Subject: Fix Error 500 when comparing non-existing branches Closes #2593 --- app/services/compare_service.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'app/services') diff --git a/app/services/compare_service.rb b/app/services/compare_service.rb index 70f642baaaa..bfe6a3dc4be 100644 --- a/app/services/compare_service.rb +++ b/app/services/compare_service.rb @@ -4,7 +4,10 @@ require 'securerandom' # and return Gitlab::CompareResult object that responds to commits and diffs class CompareService def execute(source_project, source_branch, target_project, target_branch) - source_sha = source_project.commit(source_branch).sha + source_commit = source_project.commit(source_branch) + return unless source_commit + + source_sha = source_commit.sha # If compare with other project we need to fetch ref first unless target_project == source_project -- cgit v1.2.1