Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
b58af356
Commit
b58af356
authored
Jan 14, 2021
by
Gary Holtz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding documentation, a changelog, and review suggestions
parent
01b811ca
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
12 additions
and
6 deletions
+12
-6
changelogs/unreleased/25381-add-a-custom-commit-message-when-applying-a-suggested-change.yml
...ustom-commit-message-when-applying-a-suggested-change.yml
+5
-0
doc/api/suggestions.md
doc/api/suggestions.md
+1
-0
lib/api/suggestions.rb
lib/api/suggestions.rb
+4
-4
spec/requests/api/suggestions_spec.rb
spec/requests/api/suggestions_spec.rb
+2
-2
No files found.
changelogs/unreleased/25381-add-a-custom-commit-message-when-applying-a-suggested-change.yml
0 → 100644
View file @
b58af356
---
title
:
Add a commit message parameter for the suggestion endpoints
merge_request
:
51245
author
:
type
:
added
doc/api/suggestions.md
View file @
b58af356
...
...
@@ -21,6 +21,7 @@ PUT /suggestions/:id/apply
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
|
`id`
| integer/string | yes | The ID of a suggestion |
|
`commit_message`
| string | no | A custom commit message to use instead of the default generated message or the project's default message |
```
shell
curl
--request
PUT
--header
"PRIVATE-TOKEN: <your_access_token>"
"https://gitlab.example.com/api/v4/suggestions/5/apply"
...
...
lib/api/suggestions.rb
View file @
b58af356
...
...
@@ -12,13 +12,13 @@ module API
end
params
do
requires
:id
,
type:
String
,
desc:
'The suggestion ID'
optional
:
message
,
type:
String
,
desc:
'A commit message to use instead of the default generated message or project default message'
optional
:
commit_message
,
type:
String
,
desc:
"A custom commit message to use instead of the default generated message or the project's default message"
end
put
':id/apply'
do
suggestion
=
Suggestion
.
find_by_id
(
params
[
:id
])
if
suggestion
apply_suggestions
(
suggestion
,
current_user
,
params
[
:message
])
apply_suggestions
(
suggestion
,
current_user
,
params
[
:
commit_
message
])
else
render_api_error!
(
_
(
'Suggestion is not applicable as the suggestion was not found.'
),
:not_found
)
end
...
...
@@ -29,7 +29,7 @@ module API
end
params
do
requires
:ids
,
type:
Array
[
Integer
],
coerce_with:
::
API
::
Validations
::
Types
::
CommaSeparatedToIntegerArray
.
coerce
,
desc:
"An array of suggestion ID's"
optional
:
message
,
type:
String
,
desc:
'A commit message to use instead of the default generated message or project default message'
optional
:
commit_message
,
type:
String
,
desc:
"A custom commit message to use instead of the default generated message or the project's default message"
end
put
'batch_apply'
do
ids
=
params
[
:ids
]
...
...
@@ -37,7 +37,7 @@ module API
suggestions
=
Suggestion
.
id_in
(
ids
)
if
suggestions
.
size
==
ids
.
length
apply_suggestions
(
suggestions
,
current_user
,
params
[
:message
])
apply_suggestions
(
suggestions
,
current_user
,
params
[
:
commit_
message
])
else
render_api_error!
(
_
(
'Suggestions are not applicable as one or more suggestions were not found.'
),
:not_found
)
end
...
...
spec/requests/api/suggestions_spec.rb
View file @
b58af356
...
...
@@ -71,7 +71,7 @@ RSpec.describe API::Suggestions do
message
=
"cool custom commit message!"
put
api
(
url
,
user
),
params:
{
message:
message
}
put
api
(
url
,
user
),
params:
{
commit_
message:
message
}
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
project
.
repository
.
commit
.
message
).
to
eq
(
message
)
...
...
@@ -143,7 +143,7 @@ RSpec.describe API::Suggestions do
message
=
"cool custom commit message!"
put
api
(
url
,
user
),
params:
{
ids:
[
suggestion
.
id
,
suggestion2
.
id
],
message:
message
}
commit_
message:
message
}
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
project
.
repository
.
commit
.
message
).
to
eq
(
message
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment