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
ceaee58c
Commit
ceaee58c
authored
Aug 21, 2018
by
Robert Schilling
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
API: Catch empty commit messages
parent
cc9764ac
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
1 deletion
+18
-1
changelogs/unreleased/api-empty-commit-message.yml
changelogs/unreleased/api-empty-commit-message.yml
+5
-0
lib/api/files.rb
lib/api/files.rb
+1
-1
spec/requests/api/files_spec.rb
spec/requests/api/files_spec.rb
+12
-0
No files found.
changelogs/unreleased/api-empty-commit-message.yml
0 → 100644
View file @
ceaee58c
---
title
:
'
API:
Catch
empty
commit
messages'
merge_request
:
21322
author
:
Robert Schilling
type
:
fixed
lib/api/files.rb
View file @
ceaee58c
...
@@ -59,7 +59,7 @@ module API
...
@@ -59,7 +59,7 @@ module API
params
:simple_file_params
do
params
:simple_file_params
do
requires
:file_path
,
type:
String
,
desc:
'The url encoded path to the file. Ex. lib%2Fclass%2Erb'
requires
:file_path
,
type:
String
,
desc:
'The url encoded path to the file. Ex. lib%2Fclass%2Erb'
requires
:branch
,
type:
String
,
desc:
'Name of the branch to commit into. To create a new branch, also provide `start_branch`.'
requires
:branch
,
type:
String
,
desc:
'Name of the branch to commit into. To create a new branch, also provide `start_branch`.'
requires
:commit_message
,
type:
String
,
desc:
'Commit message'
requires
:commit_message
,
type:
String
,
regexp:
/^\S+$/
,
desc:
'Commit message'
optional
:start_branch
,
type:
String
,
desc:
'Name of the branch to start the new commit from'
optional
:start_branch
,
type:
String
,
desc:
'Name of the branch to start the new commit from'
optional
:author_email
,
type:
String
,
desc:
'The email of the author'
optional
:author_email
,
type:
String
,
desc:
'The email of the author'
optional
:author_name
,
type:
String
,
desc:
'The name of the author'
optional
:author_name
,
type:
String
,
desc:
'The name of the author'
...
...
spec/requests/api/files_spec.rb
View file @
ceaee58c
...
@@ -337,6 +337,18 @@ describe API::Files do
...
@@ -337,6 +337,18 @@ describe API::Files do
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
response
).
to
have_gitlab_http_status
(
400
)
end
end
it
'returns a 400 bad request if the commit message is empty'
do
invalid_params
=
{
branch:
'master'
,
content:
'puts 8'
,
commit_message:
''
}
post
api
(
route
(
file_path
),
user
),
invalid_params
expect
(
response
).
to
have_gitlab_http_status
(
400
)
end
it
"returns a 400 if editor fails to create file"
do
it
"returns a 400 if editor fails to create file"
do
allow_any_instance_of
(
Repository
).
to
receive
(
:create_file
)
allow_any_instance_of
(
Repository
).
to
receive
(
:create_file
)
.
and_raise
(
Gitlab
::
Git
::
CommitError
,
'Cannot create file'
)
.
and_raise
(
Gitlab
::
Git
::
CommitError
,
'Cannot create file'
)
...
...
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