diff options
author | Bob Van Landuyt <bob@vanlanduyt.co> | 2018-10-11 16:27:04 +0200 |
---|---|---|
committer | Bob Van Landuyt <bob@vanlanduyt.co> | 2018-10-12 11:41:22 +0200 |
commit | 71d71afb3ac5f302470e66ace4f59e247249d99e (patch) | |
tree | 0d869436e2ab72454ebb117cc3808ad764652e55 /lib | |
parent | 75723034cee27d387d7ac7edb88d1520bb3a6b7b (diff) | |
download | gitlab-ce-71d71afb3ac5f302470e66ace4f59e247249d99e.tar.gz |
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 'lib')
-rw-r--r-- | lib/api/repositories.rb | 9 | ||||
-rw-r--r-- | lib/gitlab/git/repository.rb | 4 |
2 files changed, 4 insertions, 9 deletions
diff --git a/lib/api/repositories.rb b/lib/api/repositories.rb index 5125f302fbb..dc844c0bd27 100644 --- a/lib/api/repositories.rb +++ b/lib/api/repositories.rb @@ -130,18 +130,13 @@ module API success Entities::Commit end params do - # For now we just support 2 refs passed, but `merge-base` supports - # multiple defining this as an Array instead of 2 separate params will - # make sure we don't need to deprecate this API in favor of one - # supporting multiple commits when this functionality gets added to - # Gitaly requires :refs, type: Array[String] end get ':id/repository/merge_base' do refs = params[:refs] - unless refs.size == 2 - render_api_error!('Provide exactly 2 refs', 400) + if refs.size < 2 + render_api_error!('Provide at least 2 refs', 400) end merge_base = Gitlab::Git::MergeBase.new(user_project.repository, refs) diff --git a/lib/gitlab/git/repository.rb b/lib/gitlab/git/repository.rb index 4218e812146..9df04372cc2 100644 --- a/lib/gitlab/git/repository.rb +++ b/lib/gitlab/git/repository.rb @@ -382,9 +382,9 @@ module Gitlab end # Returns the SHA of the most recent common ancestor of +from+ and +to+ - def merge_base(from, to) + def merge_base(*commits) wrapped_gitaly_errors do - gitaly_repository_client.find_merge_base(from, to) + gitaly_repository_client.find_merge_base(*commits) end end |