debian-mirror-gitlab/app/services/compare_service.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

26 lines
811 B
Ruby
Raw Normal View History

2018-11-18 11:00:15 +05:30
# frozen_string_literal: true
2015-09-25 12:07:36 +05:30
require 'securerandom'
2018-03-17 18:26:18 +05:30
# Compare 2 refs for one repo or between repositories
2019-07-31 22:56:46 +05:30
# and return Compare object that responds to commits and diffs
2014-09-02 18:07:02 +05:30
class CompareService
2018-03-17 18:26:18 +05:30
attr_reader :start_project, :start_ref_name
2015-09-25 12:07:36 +05:30
2018-03-17 18:26:18 +05:30
def initialize(new_start_project, new_start_ref_name)
2017-08-17 22:00:37 +05:30
@start_project = new_start_project
2018-03-17 18:26:18 +05:30
@start_ref_name = new_start_ref_name
2017-08-17 22:00:37 +05:30
end
2015-09-25 12:07:36 +05:30
2018-03-27 19:54:05 +05:30
def execute(target_project, target_ref, base_sha: nil, straight: false)
2018-03-17 18:26:18 +05:30
raw_compare = target_project.repository.compare_source_branch(target_ref, start_project.repository, start_ref_name, straight: straight)
2015-09-25 12:07:36 +05:30
2019-07-31 22:56:46 +05:30
return unless raw_compare && raw_compare.base && raw_compare.head
2018-03-27 19:54:05 +05:30
Compare.new(raw_compare,
2020-02-01 01:16:34 +05:30
start_project,
2018-03-27 19:54:05 +05:30
base_sha: base_sha,
straight: straight)
2014-09-02 18:07:02 +05:30
end
end