Commit 7d37e345 authored by Nick Thomas's avatar Nick Thomas

Merge branch '56014-api-merge-request-squash-commit-messages' into 'master'

API support for setting squash commit message during squash

Closes #56014

See merge request gitlab-org/gitlab-ce!24784
parents 04131663 b3726600
---
title: API allows setting the squash commit message when squashing a merge request
merge_request: 24784
author:
type: added
...@@ -994,6 +994,8 @@ Parameters: ...@@ -994,6 +994,8 @@ Parameters:
- `id` (required) - The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) owned by the authenticated user - `id` (required) - The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) owned by the authenticated user
- `merge_request_iid` (required) - Internal ID of MR - `merge_request_iid` (required) - Internal ID of MR
- `merge_commit_message` (optional) - Custom merge commit message - `merge_commit_message` (optional) - Custom merge commit message
- `squash_commit_message` (optional) - Custom squash commit message
- `squash` (optional) - if `true` the commits will be squashed into a single commit on merge
- `should_remove_source_branch` (optional) - if `true` removes the source branch - `should_remove_source_branch` (optional) - if `true` removes the source branch
- `merge_when_pipeline_succeeds` (optional) - if `true` the MR is merged when the pipeline succeeds - `merge_when_pipeline_succeeds` (optional) - if `true` the MR is merged when the pipeline succeeds
- `sha` (optional) - if present, then this SHA must match the HEAD of the source branch, otherwise the merge will fail - `sha` (optional) - if present, then this SHA must match the HEAD of the source branch, otherwise the merge will fail
......
...@@ -343,6 +343,7 @@ module API ...@@ -343,6 +343,7 @@ module API
end end
params do params do
optional :merge_commit_message, type: String, desc: 'Custom merge commit message' optional :merge_commit_message, type: String, desc: 'Custom merge commit message'
optional :squash_commit_message, type: String, desc: 'Custom squash commit message'
optional :should_remove_source_branch, type: Boolean, optional :should_remove_source_branch, type: Boolean,
desc: 'When true, the source branch will be deleted if possible' desc: 'When true, the source branch will be deleted if possible'
optional :merge_when_pipeline_succeeds, type: Boolean, optional :merge_when_pipeline_succeeds, type: Boolean,
...@@ -370,6 +371,7 @@ module API ...@@ -370,6 +371,7 @@ module API
merge_params = { merge_params = {
commit_message: params[:merge_commit_message], commit_message: params[:merge_commit_message],
squash_commit_message: params[:squash_commit_message],
should_remove_source_branch: params[:should_remove_source_branch] should_remove_source_branch: params[:should_remove_source_branch]
} }
......
...@@ -951,6 +951,29 @@ describe API::MergeRequests do ...@@ -951,6 +951,29 @@ describe API::MergeRequests do
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(404)
end end
describe "the squash_commit_message param" do
let(:squash_commit) do
project.repository.commits_between(json_response['diff_refs']['start_sha'], json_response['merge_commit_sha']).first
end
it "results in a specific squash commit message when set" do
squash_commit_message = 'My custom squash commit message'
put api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/merge", user), params: {
squash: true,
squash_commit_message: squash_commit_message
}
expect(squash_commit.message.chomp).to eq(squash_commit_message)
end
it "results in a default squash commit message when not set" do
put api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/merge", user), params: { squash: true }
expect(squash_commit.message).to eq(merge_request.default_squash_commit_message)
end
end
end end
describe "PUT /projects/:id/merge_requests/:merge_request_iid" do describe "PUT /projects/:id/merge_requests/:merge_request_iid" do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment