summaryrefslogtreecommitdiff
path: root/app/services/compare_service.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/services/compare_service.rb')
-rw-r--r--app/services/compare_service.rb5
1 files changed, 4 insertions, 1 deletions
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