Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorblackst0ne <blackst0ne.ru@gmail.com>2018-05-29 12:51:43 +0300
committerblackst0ne <blackst0ne.ru@gmail.com>2018-05-29 12:51:43 +0300
commit4cff66a6c46361e8d775ea3f5a80bf147d4020b3 (patch)
treef1f76411400f35f394fedd28ad03d42ccbaf990e /lib
parent6e354cb642f911dc71be3d5368f066900fc25970 (diff)
Add 'squash and rebase' feature to CE
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 174c5af91d5..b630fd54354 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]