BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
0b68a0e7
Unverified
Commit
0b68a0e7
authored
Dec 04, 2015
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add API endpoint to fetch merge request commits list
Signed-off-by:
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
parent
0ccd7de7
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
73 additions
and
0 deletions
+73
-0
CHANGELOG
CHANGELOG
+1
-0
merge_requests.md
doc/api/merge_requests.md
+39
-0
merge_requests.rb
lib/api/merge_requests.rb
+16
-0
merge_requests_spec.rb
spec/requests/api/merge_requests_spec.rb
+17
-0
No files found.
CHANGELOG
View file @
0b68a0e7
...
...
@@ -7,6 +7,7 @@ v 8.3.0 (unreleased)
- Add ignore whitespace change option to commit view
- Fire update hook from GitLab
- Don't show project fork event as "imported"
- Add API endpoint to fetch merge request commits list
v 8.2.2
- Fix 404 in redirection after removing a project (Stan Hu)
...
...
doc/api/merge_requests.md
View file @
0b68a0e7
...
...
@@ -101,6 +101,45 @@ Parameters:
}
```
## Get single MR commits
Get a list of repository commits in a merge request.
```
GET /projects/:id/merge_request/:merge_request_id/commits
```
Parameters:
-
`id`
(required) - The ID of a project
-
`merge_request_id`
(required) - The ID of MR
```json
[
{
"id": "ed899a2f4b50b4370feeea94676502b42383c746",
"short_id": "ed899a2f4b5",
"title": "Replace sanitize with escape once",
"author_name": "Dmitriy Zaporozhets",
"author_email": "dzaporozhets@sphereconsultinginc.com",
"created_at": "2012-09-20T11:50:22+03:00",
"message": "Replace sanitize with escape once",
"allow_failure": false
},
{
"id": "6104942438c14ec7bd21c6cd5bd995272b3faff6",
"short_id": "6104942438c",
"title": "Sanitize for network graph",
"author_name": "randx",
"author_email": "dmitriy.zaporozhets@gmail.com",
"created_at": "2012-09-20T09:06:12+03:00",
"message": "Sanitize for network graph",
"allow_failure": false
}
]
```
## Get single MR changes
Shows information about the merge request including its files and changes.
...
...
lib/api/merge_requests.rb
View file @
0b68a0e7
...
...
@@ -76,6 +76,22 @@ module API
present
merge_request
,
with:
Entities
::
MergeRequest
end
# Show MR commits
#
# Parameters:
# id (required) - The ID of a project
# merge_request_id (required) - The ID of MR
#
# Example:
# GET /projects/:id/merge_request/:merge_request_id/commits
#
get
':id/merge_request/:merge_request_id/commits'
do
merge_request
=
user_project
.
merge_requests
.
find
(
params
[
:merge_request_id
])
authorize!
:read_merge_request
,
merge_request
present
merge_request
.
commits
,
with:
Entities
::
RepoCommit
end
# Show MR changes
#
# Parameters:
...
...
spec/requests/api/merge_requests_spec.rb
View file @
0b68a0e7
...
...
@@ -131,6 +131,23 @@ describe API::API, api: true do
end
end
describe
'GET /projects/:id/merge_request/:merge_request_id/commits'
do
context
'valid merge request'
do
before
{
get
api
(
"/projects/
#{
project
.
id
}
/merge_request/
#{
merge_request
.
id
}
/commits"
,
user
)
}
let
(
:commit
)
{
merge_request
.
commits
.
first
}
it
{
expect
(
response
.
status
).
to
eq
200
}
it
{
expect
(
json_response
.
size
).
to
eq
(
merge_request
.
commits
.
size
)
}
it
{
expect
(
json_response
.
first
[
'id'
]).
to
eq
(
commit
.
id
)
}
it
{
expect
(
json_response
.
first
[
'title'
]).
to
eq
(
commit
.
title
)
}
end
it
'returns a 404 when merge_request_id not found'
do
get
api
(
"/projects/
#{
project
.
id
}
/merge_request/999/commits"
,
user
)
expect
(
response
.
status
).
to
eq
(
404
)
end
end
describe
'GET /projects/:id/merge_request/:merge_request_id/changes'
do
it
'should return the change information of the merge_request'
do
get
api
(
"/projects/
#{
project
.
id
}
/merge_request/
#{
merge_request
.
id
}
/changes"
,
user
)
...
...
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