summaryrefslogtreecommitdiff
path: root/app/services/compare_service.rb
blob: 48ad7fab4e62f2c1b08e78a82bd5d485b4149412 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# Compare 2 branches for one repo or between repositories
# and return Gitlab::CompareResult object that responds to commits and diffs
class CompareService
  def execute(current_user, source_project, source_branch, target_project, target_branch)
    # Try to compare branches to get commits list and diffs
    if target_project == source_project
      Gitlab::CompareResult.new(
        Gitlab::Git::Compare.new(
          target_project.repository.raw_repository,
          target_branch,
          source_branch,
        )
      )
    else
      raise 'Implement me'
    end
  end
end