diff options
author | Stan Hu <stanhu@gmail.com> | 2019-04-14 07:26:03 -0700 |
---|---|---|
committer | Oswaldo Ferreira <> | 2019-04-18 22:01:51 -0300 |
commit | 5d74c95c988cdd9c1c761de3a78c3dc191e4fe52 (patch) | |
tree | f6d0c19e4b591a08fc50ae1b2d4f9252f59ea747 /app | |
parent | 54d64ec9f62f5c271b3ed649530a3a2eaa482206 (diff) | |
download | gitlab-ce-5d74c95c988cdd9c1c761de3a78c3dc191e4fe52.tar.gz |
Check that source and target branch exist
This ensures the return value is consistent if the source and/or
branch do not exist.
Diffstat (limited to 'app')
-rw-r--r-- | app/services/compare_service.rb | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/app/services/compare_service.rb b/app/services/compare_service.rb index 3adf8a0c1a1..3f0aedfbfb2 100644 --- a/app/services/compare_service.rb +++ b/app/services/compare_service.rb @@ -3,7 +3,7 @@ require 'securerandom' # Compare 2 refs for one repo or between repositories -# and return Gitlab::Git::Compare object that responds to commits and diffs +# and return Compare object that responds to commits and diffs class CompareService attr_reader :start_project, :start_ref_name @@ -15,7 +15,7 @@ class CompareService def execute(target_project, target_ref, base_sha: nil, straight: false) raw_compare = target_project.repository.compare_source_branch(target_ref, start_project.repository, start_ref_name, straight: straight) - return unless raw_compare + return unless raw_compare && raw_compare.base && raw_compare.head Compare.new(raw_compare, target_project, |