diff options
author | Douwe Maan <douwe@gitlab.com> | 2018-10-15 19:18:21 +0300 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2018-10-15 19:18:21 +0300 |
commit | 3c15a20ba33b076eabca0335f91065e7cbe2d08b (patch) | |
tree | 04252c2488c67f15b89d36a425c8b862cc466a06 /lib | |
parent | 422715b2248535be9521c6499b94090ac90b394c (diff) | |
parent | 71d71afb3ac5f302470e66ace4f59e247249d99e (diff) |
Merge branch 'bvl-merge-base-multiple-revisions' into 'master'
Allow getting the merge base of multiple revisions
Closes #52573
See merge request gitlab-org/gitlab-ce!22295
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 |