2015-08-11 12:33:31 +00:00
|
|
|
require 'securerandom'
|
|
|
|
|
2014-07-29 09:11:16 +00:00
|
|
|
# Compare 2 branches for one repo or between repositories
|
2016-03-03 17:38:44 +00:00
|
|
|
# and return Gitlab::Git::Compare object that responds to commits and diffs
|
2014-07-29 09:11:16 +00:00
|
|
|
class CompareService
|
2017-01-06 15:29:13 +00:00
|
|
|
attr_reader :start_project, :start_branch_name
|
2015-09-18 19:02:01 +00:00
|
|
|
|
2017-01-06 15:29:13 +00:00
|
|
|
def initialize(new_start_project, new_start_branch_name)
|
|
|
|
@start_project = new_start_project
|
|
|
|
@start_branch_name = new_start_branch_name
|
2016-12-08 09:57:52 +00:00
|
|
|
end
|
2015-08-11 12:33:31 +00:00
|
|
|
|
2016-12-08 09:57:52 +00:00
|
|
|
def execute(target_project, target_branch, straight: false)
|
2017-08-23 15:14:21 +00:00
|
|
|
raw_compare = target_project.repository.compare_source_branch(target_branch, start_project.repository, start_branch_name, straight: straight)
|
2017-01-04 17:52:21 +00:00
|
|
|
|
2017-08-23 15:14:21 +00:00
|
|
|
Compare.new(raw_compare, target_project, straight: straight) if raw_compare
|
2014-07-29 09:11:16 +00:00
|
|
|
end
|
|
|
|
end
|