summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorPhil Hughes <me@iamphill.com>2018-05-30 07:38:31 +0000
committerPhil Hughes <me@iamphill.com>2018-05-30 07:38:31 +0000
commitfd79df64c5411308e67a62b4c02a07f5317ddec1 (patch)
tree8f923668b4abebc14cba1923acdd7700a8f3ba96 /lib
parente869387ca27f9a9ac34f6398876714199fc3100e (diff)
parent4cff66a6c46361e8d775ea3f5a80bf147d4020b3 (diff)
downloadgitlab-ce-fd79df64c5411308e67a62b4c02a07f5317ddec1.tar.gz
Merge branch 'blackst0ne-squash-and-merge-in-gitlab-core-ce' into 'master'
Resolve "Squash and merge in GitLab Core (CE)" Closes #34591 See merge request gitlab-org/gitlab-ce!18956
Diffstat (limited to 'lib')
-rw-r--r--lib/api/entities.rb2
-rw-r--r--lib/api/merge_requests.rb13
-rw-r--r--lib/api/v3/entities.rb2
-rw-r--r--lib/api/v3/merge_requests.rb6
4 files changed, 13 insertions, 10 deletions
diff --git a/lib/api/entities.rb b/lib/api/entities.rb
index 3688b44b8df..49cd4fccc63 100644
--- a/lib/api/entities.rb
+++ b/lib/api/entities.rb
@@ -568,6 +568,8 @@ module API
expose :time_stats, using: 'API::Entities::IssuableTimeStats' do |merge_request|
merge_request
end
+
+ expose :squash
end
class MergeRequest < MergeRequestBasic
diff --git a/lib/api/merge_requests.rb b/lib/api/merge_requests.rb
index bc4df16e3a8..1ba9a09346f 100644
--- a/lib/api/merge_requests.rb
+++ b/lib/api/merge_requests.rb
@@ -10,12 +10,6 @@ module API
helpers do
params :optional_params_ee do
end
-
- params :merge_params_ee do
- end
-
- def update_merge_request_ee(merge_request)
- end
end
def self.update_params_at_least_one_of
@@ -29,6 +23,7 @@ module API
target_branch
title
discussion_locked
+ squash
]
end
@@ -146,6 +141,7 @@ module API
optional :labels, type: String, desc: 'Comma-separated list of label names'
optional :remove_source_branch, type: Boolean, desc: 'Remove source branch when merging'
optional :allow_maintainer_to_push, type: Boolean, desc: 'Whether a maintainer of the target project can push to the source project'
+ optional :squash, type: Grape::API::Boolean, desc: 'When true, the commits will be squashed into a single commit on merge'
use :optional_params_ee
end
@@ -308,8 +304,7 @@ module API
optional :merge_when_pipeline_succeeds, type: Boolean,
desc: 'When true, this merge request will be merged when the pipeline succeeds'
optional :sha, type: String, desc: 'When present, must have the HEAD SHA of the source branch'
-
- use :merge_params_ee
+ optional :squash, type: Grape::API::Boolean, desc: 'When true, the commits will be squashed into a single commit on merge'
end
put ':id/merge_requests/:merge_request_iid/merge' do
Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab-ce/issues/42317')
@@ -327,7 +322,7 @@ module API
check_sha_param!(params, merge_request)
- update_merge_request_ee(merge_request)
+ merge_request.update(squash: params[:squash]) if params[:squash]
merge_params = {
commit_message: params[:merge_commit_message],
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]