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
fc13ea71
Commit
fc13ea71
authored
Feb 04, 2015
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #8712 from jvanbaarsen/add-merge-request-files-endpoint
Added a way to retrieve MR files
parents
61d07eab
b60d06eb
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
111 additions
and
6 deletions
+111
-6
CHANGELOG
CHANGELOG
+1
-1
doc/api/merge_requests.md
doc/api/merge_requests.md
+70
-0
lib/api/entities.rb
lib/api/entities.rb
+11
-5
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
+13
-0
No files found.
CHANGELOG
View file @
fc13ea71
...
...
@@ -8,7 +8,7 @@ v 7.8.0
- Better UI for project services page
- Cleaner UI for web editor
- Add diff syntax highlighting in email-on-push service notifications (Hannes Rosenögger)
-
-
Add API endpoint to fetch all changes on a MergeRequest (Jeroen van Baarsen)
-
-
- Allow more variations for commit messages closing issues (Julien Bianchi and Hannes Rosenögger)
...
...
doc/api/merge_requests.md
View file @
fc13ea71
...
...
@@ -94,6 +94,76 @@ Parameters:
}
```
## Get single MR changes
Shows information about the merge request including its files and changes
```
GET /projects/:id/merge_request/:merge_request_id/changes
```
Parameters:
-
`id`
(required) - The ID of a project
-
`merge_request_id`
(required) - The ID of MR
```
json
{
"id"
:
21
,
"iid"
:
1
,
"project_id"
:
4
,
"title"
:
"Blanditiis beatae suscipit hic assumenda et molestias nisi asperiores repellat et."
,
"description"
:
"Qui voluptatibus placeat ipsa alias quasi. Deleniti rem ut sint. Optio velit qui distinctio."
,
"state"
:
"reopened"
,
"created_at"
:
"2015-02-02T19:49:39.159Z"
,
"updated_at"
:
"2015-02-02T20:08:49.959Z"
,
"target_branch"
:
"secret_token"
,
"source_branch"
:
"version-1-9"
,
"upvotes"
:
0
,
"downvotes"
:
0
,
"author"
:
{
"name"
:
"Chad Hamill"
,
"username"
:
"jarrett"
,
"id"
:
5
,
"state"
:
"active"
,
"avatar_url"
:
"http://www.gravatar.com/avatar/b95567800f828948baf5f4160ebb2473?s=40&d=identicon"
},
"assignee"
:
{
"name"
:
"Administrator"
,
"username"
:
"root"
,
"id"
:
1
,
"state"
:
"active"
,
"avatar_url"
:
"http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=40&d=identicon"
},
"source_project_id"
:
4
,
"target_project_id"
:
4
,
"labels"
:
[
],
"milestone"
:
{
"id"
:
5
,
"iid"
:
1
,
"project_id"
:
4
,
"title"
:
"v2.0"
,
"description"
:
"Assumenda aut placeat expedita exercitationem labore sunt enim earum."
,
"state"
:
"closed"
,
"created_at"
:
"2015-02-02T19:49:26.013Z"
,
"updated_at"
:
"2015-02-02T19:49:26.013Z"
,
"due_date"
:
null
},
"files"
:
[
{
"old_path"
:
"VERSION"
,
"new_path"
:
"VERSION"
,
"a_mode"
:
"100644"
,
"b_mode"
:
"100644"
,
"diff"
:
"--- a/VERSION
\
+++ b/VERSION
\
@@ -1 +1 @@
\
-1.9.7
\
+1.9.8"
,
"new_file"
:
false
,
"renamed_file"
:
false
,
"deleted_file"
:
false
}
]
}
```
## Create MR
Creates a new merge request.
...
...
lib/api/entities.rb
View file @
fc13ea71
...
...
@@ -147,6 +147,11 @@ module API
expose
:state
,
:created_at
,
:updated_at
end
class
RepoDiff
<
Grape
::
Entity
expose
:old_path
,
:new_path
,
:a_mode
,
:b_mode
,
:diff
expose
:new_file
,
:renamed_file
,
:deleted_file
end
class
Milestone
<
ProjectEntity
expose
:due_date
end
...
...
@@ -166,6 +171,12 @@ module API
expose
:milestone
,
using:
Entities
::
Milestone
end
class
MergeRequestChanges
<
MergeRequest
expose
:diffs
,
as: :changes
,
using:
Entities
::
RepoDiff
do
|
compare
,
_
|
compare
.
diffs
end
end
class
SSHKey
<
Grape
::
Entity
expose
:id
,
:title
,
:key
,
:created_at
end
...
...
@@ -236,11 +247,6 @@ module API
expose
:name
,
:color
end
class
RepoDiff
<
Grape
::
Entity
expose
:old_path
,
:new_path
,
:a_mode
,
:b_mode
,
:diff
expose
:new_file
,
:renamed_file
,
:deleted_file
end
class
Compare
<
Grape
::
Entity
expose
:commit
,
using:
Entities
::
RepoCommit
do
|
compare
,
options
|
Commit
.
decorate
(
compare
.
commits
).
last
...
...
lib/api/merge_requests.rb
View file @
fc13ea71
...
...
@@ -75,6 +75,22 @@ module API
present
merge_request
,
with:
Entities
::
MergeRequest
end
# Show MR changes
#
# 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/changes
#
get
':id/merge_request/:merge_request_id/changes'
do
merge_request
=
user_project
.
merge_requests
.
find
(
params
[
:merge_request_id
])
authorize!
:read_merge_request
,
merge_request
present
merge_request
,
with:
Entities
::
MergeRequestChanges
end
# Create MR
#
# Parameters:
...
...
spec/requests/api/merge_requests_spec.rb
View file @
fc13ea71
...
...
@@ -114,6 +114,19 @@ describe API::API, api: true do
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
)
expect
(
response
.
status
).
to
eq
200
expect
(
json_response
[
'changes'
].
size
).
to
eq
(
merge_request
.
diffs
.
size
)
end
it
'returns a 404 when merge_request_id not found'
do
get
api
(
"/projects/
#{
project
.
id
}
/merge_request/999/changes"
,
user
)
expect
(
response
.
status
).
to
eq
(
404
)
end
end
describe
"POST /projects/:id/merge_requests"
do
context
'between branches projects'
do
it
"should return merge_request"
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