diff options
author | Bob Van Landuyt <bob@vanlanduyt.co> | 2018-10-11 17:27:04 +0300 |
---|---|---|
committer | Bob Van Landuyt <bob@vanlanduyt.co> | 2018-10-12 12:41:22 +0300 |
commit | 71d71afb3ac5f302470e66ace4f59e247249d99e (patch) | |
tree | 0d869436e2ab72454ebb117cc3808ad764652e55 /app | |
parent | 75723034cee27d387d7ac7edb88d1520bb3a6b7b (diff) |
Allow getting the merge base of multiple revisions
As we now support getting the merge base for multiple revisions in
gitaly, we can provide this functionality in our API
Diffstat (limited to 'app')
-rw-r--r-- | app/models/repository.rb | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/app/models/repository.rb b/app/models/repository.rb index a3a3ce179fc..2c28ea64066 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -881,10 +881,12 @@ class Repository delegate :merged_branch_names, to: :raw_repository - def merge_base(first_commit_id, second_commit_id) - first_commit_id = commit(first_commit_id).try(:id) || first_commit_id - second_commit_id = commit(second_commit_id).try(:id) || second_commit_id - raw_repository.merge_base(first_commit_id, second_commit_id) + def merge_base(*commits_or_ids) + commit_ids = commits_or_ids.map do |commit_or_id| + commit_or_id.is_a?(::Commit) ? commit_or_id.id : commit_or_id + end + + raw_repository.merge_base(*commit_ids) end def ancestor?(ancestor_id, descendant_id) |