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

19 lines
655 B
Ruby
Raw Normal View History

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
2016-06-02 11:05:42 +05:30
# and return Gitlab::Git::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-17 18:26:18 +05:30
def execute(target_project, target_ref, straight: false)
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
2018-03-17 18:26:18 +05:30
Compare.new(raw_compare, target_project, straight: straight) if raw_compare
2014-09-02 18:07:02 +05:30
end
end