summaryrefslogtreecommitdiff
path: root/lib/api/v3
diff options
context:
space:
mode:
authorblackst0ne <blackst0ne.ru@gmail.com>2018-05-29 20:51:43 +1100
committerblackst0ne <blackst0ne.ru@gmail.com>2018-05-29 20:51:43 +1100
commit4cff66a6c46361e8d775ea3f5a80bf147d4020b3 (patch)
treef1f76411400f35f394fedd28ad03d42ccbaf990e /lib/api/v3
parent6e354cb642f911dc71be3d5368f066900fc25970 (diff)
downloadgitlab-ce-4cff66a6c46361e8d775ea3f5a80bf147d4020b3.tar.gz
Add 'squash and rebase' feature to CEblackst0ne-squash-and-merge-in-gitlab-core-ce
Diffstat (limited to 'lib/api/v3')
-rw-r--r--lib/api/v3/entities.rb2
-rw-r--r--lib/api/v3/merge_requests.rb6
2 files changed, 7 insertions, 1 deletions
diff --git a/lib/api/v3/entities.rb b/lib/api/v3/entities.rb
index 68b4d7c3982..28fcf6c6e84 100644
--- a/lib/api/v3/entities.rb
+++ b/lib/api/v3/entities.rb
@@ -134,6 +134,8 @@ module API
expose :should_remove_source_branch?, as: :should_remove_source_branch
expose :force_remove_source_branch?, as: :force_remove_source_branch
+ expose :squash
+
expose :web_url do |merge_request, options|
Gitlab::UrlBuilder.build(merge_request)
end
diff --git a/lib/api/v3/merge_requests.rb b/lib/api/v3/merge_requests.rb
index 9b0f70e2bfe..af5afd1c334 100644
--- a/lib/api/v3/merge_requests.rb
+++ b/lib/api/v3/merge_requests.rb
@@ -44,6 +44,7 @@ module API
optional :milestone_id, type: Integer, desc: 'The ID of a milestone to assign the merge request'
optional :labels, type: String, desc: 'Comma-separated list of label names'
optional :remove_source_branch, type: Boolean, desc: 'Remove source branch when merging'
+ optional :squash, type: Boolean, desc: 'Squash commits when merging'
end
end
@@ -166,7 +167,7 @@ module API
use :optional_params
at_least_one_of :title, :target_branch, :description, :assignee_id,
:milestone_id, :labels, :state_event,
- :remove_source_branch
+ :remove_source_branch, :squash
end
put path do
Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab-ce/issues/42127')
@@ -195,6 +196,7 @@ module API
optional :merge_when_build_succeeds, type: Boolean,
desc: 'When true, this merge request will be merged when the build succeeds'
optional :sha, type: String, desc: 'When present, must have the HEAD SHA of the source branch'
+ optional :squash, type: Boolean, desc: 'When true, the commits will be squashed into a single commit on merge'
end
put "#{path}/merge" do
merge_request = find_project_merge_request(params[:merge_request_id])
@@ -211,6 +213,8 @@ module API
render_api_error!("SHA does not match HEAD of source branch: #{merge_request.diff_head_sha}", 409)
end
+ merge_request.update(squash: params[:squash]) if params[:squash]
+
merge_params = {
commit_message: params[:merge_commit_message],
should_remove_source_branch: params[:should_remove_source_branch]