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
iv
gitlab-ce
Commits
17fd0e5c
Commit
17fd0e5c
authored
Mar 26, 2014
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #6569 from criteo/api_merge_request_comments
Add method to get the comments on a merge request
parents
af0b59d4
9886998f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
75 additions
and
0 deletions
+75
-0
doc/api/merge_requests.md
doc/api/merge_requests.md
+42
-0
lib/api/merge_requests.rb
lib/api/merge_requests.rb
+16
-0
spec/requests/api/merge_requests_spec.rb
spec/requests/api/merge_requests_spec.rb
+17
-0
No files found.
doc/api/merge_requests.md
View file @
17fd0e5c
...
...
@@ -150,6 +150,7 @@ Parameters:
+
`target_branch`
- The target branch
+
`assignee_id`
- Assignee user ID
+
`title`
- Title of MR
+
`state_event`
- New state (close|reopen|merge)
```
json
...
...
@@ -210,3 +211,44 @@ Parameters:
"note"
:
"text1"
}
```
## Get the comments on a MR
Gets all the comments associated with a merge request.
```
GET /projects/:id/merge_request/:merge_request_id/comments
```
Parameters:
+
`id`
(required) - The ID of a project
+
`merge_request_id`
(required) - ID of merge request
```
json
[
{
"note"
:
"this is the 1st comment on the 2merge merge request"
,
"author"
:{
"id"
:
11
,
"username"
:
"admin"
,
"email"
:
"admin@local.host"
,
"name"
:
"Administrator"
,
"state"
:
"active"
,
"created_at"
:
"2014-03-06T08:17:35.000Z"
}
},
{
"note"
:
"_Status changed to closed_"
,
"author"
:{
"id"
:
11
,
"username"
:
"admin"
,
"email"
:
"admin@local.host"
,
"name"
:
"Administrator"
,
"state"
:
"active"
,
"created_at"
:
"2014-03-06T08:17:35.000Z"
}
}
]
```
lib/api/merge_requests.rb
View file @
17fd0e5c
...
...
@@ -125,6 +125,22 @@ module API
end
end
# Get a merge request's comments
#
# Parameters:
# id (required) - The ID of a project
# merge_request_id (required) - ID of MR
# Examples:
# GET /projects/:id/merge_request/:merge_request_id/comments
#
get
":id/merge_request/:merge_request_id/comments"
do
merge_request
=
user_project
.
merge_requests
.
find
(
params
[
:merge_request_id
])
authorize!
:read_merge_request
,
merge_request
present
paginate
(
merge_request
.
notes
),
with:
Entities
::
MRNote
end
# Post comment to merge request
#
# Parameters:
...
...
spec/requests/api/merge_requests_spec.rb
View file @
17fd0e5c
...
...
@@ -7,6 +7,7 @@ describe API::API do
let
(
:user
)
{
create
(
:user
)
}
let!
(
:project
)
{
create
(
:project
,
creator_id:
user
.
id
,
namespace:
user
.
namespace
)
}
let!
(
:merge_request
)
{
create
(
:merge_request
,
author:
user
,
assignee:
user
,
source_project:
project
,
target_project:
project
,
title:
"Test"
)
}
let!
(
:note
)
{
create
(
:note_on_merge_request
,
author:
user
,
project:
project
,
noteable:
merge_request
,
note:
"a comment on a MR"
)
}
before
{
project
.
team
<<
[
user
,
:reporters
]
}
...
...
@@ -205,4 +206,20 @@ describe API::API do
response
.
status
.
should
==
404
end
end
describe
"GET :id/merge_request/:merge_request_id/comments"
do
it
"should return merge_request comments"
do
get
api
(
"/projects/
#{
project
.
id
}
/merge_request/
#{
merge_request
.
id
}
/comments"
,
user
)
response
.
status
.
should
==
200
json_response
.
should
be_an
Array
json_response
.
length
.
should
==
1
json_response
.
first
[
'note'
].
should
==
"a comment on a MR"
json_response
.
first
[
'author'
][
'id'
].
should
==
user
.
id
end
it
"should return a 404 error if merge_request_id not found"
do
get
api
(
"/projects/
#{
project
.
id
}
/merge_request/999/comments"
,
user
)
response
.
status
.
should
==
404
end
end
end
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