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
0
Merge Requests
0
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
Tatuya Kamada
gitlab-ce
Commits
c9abdadd
Commit
c9abdadd
authored
Mar 14, 2017
by
Rémy Coutable
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ensure dots in project path is allowed in the commits API
Signed-off-by:
Rémy Coutable
<
remy@rymai.me
>
parent
e52529e2
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
19 additions
and
17 deletions
+19
-17
lib/api/commits.rb
lib/api/commits.rb
+1
-1
lib/api/v3/commits.rb
lib/api/v3/commits.rb
+1
-1
spec/requests/api/commits_spec.rb
spec/requests/api/commits_spec.rb
+9
-8
spec/requests/api/v3/commits_spec.rb
spec/requests/api/v3/commits_spec.rb
+8
-7
No files found.
lib/api/commits.rb
View file @
c9abdadd
...
@@ -10,7 +10,7 @@ module API
...
@@ -10,7 +10,7 @@ module API
params
do
params
do
requires
:id
,
type:
String
,
desc:
'The ID of a project'
requires
:id
,
type:
String
,
desc:
'The ID of a project'
end
end
resource
:projects
do
resource
:projects
,
requirements:
{
id:
/.+/
}
do
desc
'Get a project repository commits'
do
desc
'Get a project repository commits'
do
success
Entities
::
RepoCommit
success
Entities
::
RepoCommit
end
end
...
...
lib/api/v3/commits.rb
View file @
c9abdadd
...
@@ -11,7 +11,7 @@ module API
...
@@ -11,7 +11,7 @@ module API
params
do
params
do
requires
:id
,
type:
String
,
desc:
'The ID of a project'
requires
:id
,
type:
String
,
desc:
'The ID of a project'
end
end
resource
:projects
do
resource
:projects
,
requirements:
{
id:
/.+/
}
do
desc
'Get a project repository commits'
do
desc
'Get a project repository commits'
do
success
::
API
::
Entities
::
RepoCommit
success
::
API
::
Entities
::
RepoCommit
end
end
...
...
spec/requests/api/commits_spec.rb
View file @
c9abdadd
...
@@ -178,7 +178,7 @@ describe API::Commits, api: true do
...
@@ -178,7 +178,7 @@ describe API::Commits, api: true do
end
end
end
end
describe
"
Create a commit with multiple files and action
s"
do
describe
"
POST /projects/:id/repository/commit
s"
do
let!
(
:url
)
{
"/projects/
#{
project
.
id
}
/repository/commits"
}
let!
(
:url
)
{
"/projects/
#{
project
.
id
}
/repository/commits"
}
it
'returns a 403 unauthorized for user without permissions'
do
it
'returns a 403 unauthorized for user without permissions'
do
...
@@ -193,7 +193,7 @@ describe API::Commits, api: true do
...
@@ -193,7 +193,7 @@ describe API::Commits, api: true do
expect
(
response
).
to
have_http_status
(
400
)
expect
(
response
).
to
have_http_status
(
400
)
end
end
context
:create
do
describe
'create'
do
let
(
:message
)
{
'Created file'
}
let
(
:message
)
{
'Created file'
}
let!
(
:invalid_c_params
)
do
let!
(
:invalid_c_params
)
do
{
{
...
@@ -237,8 +237,9 @@ describe API::Commits, api: true do
...
@@ -237,8 +237,9 @@ describe API::Commits, api: true do
expect
(
response
).
to
have_http_status
(
400
)
expect
(
response
).
to
have_http_status
(
400
)
end
end
context
'with project path in URL'
do
context
'with project path containing a dot in URL'
do
let
(
:url
)
{
"/projects/
#{
project
.
full_path
.
gsub
(
'/'
,
'%2F'
)
}
/repository/commits"
}
let!
(
:user
)
{
create
(
:user
,
username:
'foo.bar'
)
}
let
(
:url
)
{
"/projects/
#{
CGI
.
escape
(
project
.
full_path
)
}
/repository/commits"
}
it
'a new file in project repo'
do
it
'a new file in project repo'
do
post
api
(
url
,
user
),
valid_c_params
post
api
(
url
,
user
),
valid_c_params
...
@@ -248,7 +249,7 @@ describe API::Commits, api: true do
...
@@ -248,7 +249,7 @@ describe API::Commits, api: true do
end
end
end
end
context
:delete
do
describe
'delete'
do
let
(
:message
)
{
'Deleted file'
}
let
(
:message
)
{
'Deleted file'
}
let!
(
:invalid_d_params
)
do
let!
(
:invalid_d_params
)
do
{
{
...
@@ -289,7 +290,7 @@ describe API::Commits, api: true do
...
@@ -289,7 +290,7 @@ describe API::Commits, api: true do
end
end
end
end
context
:move
do
describe
'move'
do
let
(
:message
)
{
'Moved file'
}
let
(
:message
)
{
'Moved file'
}
let!
(
:invalid_m_params
)
do
let!
(
:invalid_m_params
)
do
{
{
...
@@ -334,7 +335,7 @@ describe API::Commits, api: true do
...
@@ -334,7 +335,7 @@ describe API::Commits, api: true do
end
end
end
end
context
:update
do
describe
'update'
do
let
(
:message
)
{
'Updated file'
}
let
(
:message
)
{
'Updated file'
}
let!
(
:invalid_u_params
)
do
let!
(
:invalid_u_params
)
do
{
{
...
@@ -377,7 +378,7 @@ describe API::Commits, api: true do
...
@@ -377,7 +378,7 @@ describe API::Commits, api: true do
end
end
end
end
context
"multiple operations"
do
describe
'multiple operations'
do
let
(
:message
)
{
'Multiple actions'
}
let
(
:message
)
{
'Multiple actions'
}
let!
(
:invalid_mo_params
)
do
let!
(
:invalid_mo_params
)
do
{
{
...
...
spec/requests/api/v3/commits_spec.rb
View file @
c9abdadd
...
@@ -88,7 +88,7 @@ describe API::V3::Commits, api: true do
...
@@ -88,7 +88,7 @@ describe API::V3::Commits, api: true do
end
end
end
end
describe
"
Create a commit with multiple files and action
s"
do
describe
"
POST /projects/:id/repository/commit
s"
do
let!
(
:url
)
{
"/projects/
#{
project
.
id
}
/repository/commits"
}
let!
(
:url
)
{
"/projects/
#{
project
.
id
}
/repository/commits"
}
it
'returns a 403 unauthorized for user without permissions'
do
it
'returns a 403 unauthorized for user without permissions'
do
...
@@ -103,7 +103,7 @@ describe API::V3::Commits, api: true do
...
@@ -103,7 +103,7 @@ describe API::V3::Commits, api: true do
expect
(
response
).
to
have_http_status
(
400
)
expect
(
response
).
to
have_http_status
(
400
)
end
end
context
:create
do
describe
'create'
do
let
(
:message
)
{
'Created file'
}
let
(
:message
)
{
'Created file'
}
let!
(
:invalid_c_params
)
do
let!
(
:invalid_c_params
)
do
{
{
...
@@ -147,8 +147,9 @@ describe API::V3::Commits, api: true do
...
@@ -147,8 +147,9 @@ describe API::V3::Commits, api: true do
expect
(
response
).
to
have_http_status
(
400
)
expect
(
response
).
to
have_http_status
(
400
)
end
end
context
'with project path in URL'
do
context
'with project path containing a dot in URL'
do
let
(
:url
)
{
"/projects/
#{
project
.
full_path
.
gsub
(
'/'
,
'%2F'
)
}
/repository/commits"
}
let!
(
:user
)
{
create
(
:user
,
username:
'foo.bar'
)
}
let
(
:url
)
{
"/projects/
#{
CGI
.
escape
(
project
.
full_path
)
}
/repository/commits"
}
it
'a new file in project repo'
do
it
'a new file in project repo'
do
post
v3_api
(
url
,
user
),
valid_c_params
post
v3_api
(
url
,
user
),
valid_c_params
...
@@ -158,7 +159,7 @@ describe API::V3::Commits, api: true do
...
@@ -158,7 +159,7 @@ describe API::V3::Commits, api: true do
end
end
end
end
context
:delete
do
describe
'delete'
do
let
(
:message
)
{
'Deleted file'
}
let
(
:message
)
{
'Deleted file'
}
let!
(
:invalid_d_params
)
do
let!
(
:invalid_d_params
)
do
{
{
...
@@ -199,7 +200,7 @@ describe API::V3::Commits, api: true do
...
@@ -199,7 +200,7 @@ describe API::V3::Commits, api: true do
end
end
end
end
context
:move
do
describe
'move'
do
let
(
:message
)
{
'Moved file'
}
let
(
:message
)
{
'Moved file'
}
let!
(
:invalid_m_params
)
do
let!
(
:invalid_m_params
)
do
{
{
...
@@ -244,7 +245,7 @@ describe API::V3::Commits, api: true do
...
@@ -244,7 +245,7 @@ describe API::V3::Commits, api: true do
end
end
end
end
context
:update
do
describe
'update'
do
let
(
:message
)
{
'Updated file'
}
let
(
:message
)
{
'Updated file'
}
let!
(
:invalid_u_params
)
do
let!
(
:invalid_u_params
)
do
{
{
...
...
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