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
Léo-Paul Géneau
gitlab-ce
Commits
b60d06eb
Commit
b60d06eb
authored
Feb 02, 2015
by
Jeroen van Baarsen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added a way to retrieve MR files
Signed-off-by:
Jeroen van Baarsen
<
jeroenvanbaarsen@gmail.com
>
parent
c0acb28c
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 @
b60d06eb
...
@@ -8,7 +8,7 @@ v 7.8.0
...
@@ -8,7 +8,7 @@ v 7.8.0
- Better UI for project services page
- Better UI for project services page
- Cleaner UI for web editor
- Cleaner UI for web editor
- Add diff syntax highlighting in email-on-push service notifications (Hannes Rosenögger)
- 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)
- Allow more variations for commit messages closing issues (Julien Bianchi and Hannes Rosenögger)
...
...
doc/api/merge_requests.md
View file @
b60d06eb
...
@@ -94,6 +94,76 @@ Parameters:
...
@@ -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
## Create MR
Creates a new merge request.
Creates a new merge request.
...
...
lib/api/entities.rb
View file @
b60d06eb
...
@@ -147,6 +147,11 @@ module API
...
@@ -147,6 +147,11 @@ module API
expose
:state
,
:created_at
,
:updated_at
expose
:state
,
:created_at
,
:updated_at
end
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
class
Milestone
<
ProjectEntity
expose
:due_date
expose
:due_date
end
end
...
@@ -166,6 +171,12 @@ module API
...
@@ -166,6 +171,12 @@ module API
expose
:milestone
,
using:
Entities
::
Milestone
expose
:milestone
,
using:
Entities
::
Milestone
end
end
class
MergeRequestChanges
<
MergeRequest
expose
:diffs
,
as: :changes
,
using:
Entities
::
RepoDiff
do
|
compare
,
_
|
compare
.
diffs
end
end
class
SSHKey
<
Grape
::
Entity
class
SSHKey
<
Grape
::
Entity
expose
:id
,
:title
,
:key
,
:created_at
expose
:id
,
:title
,
:key
,
:created_at
end
end
...
@@ -236,11 +247,6 @@ module API
...
@@ -236,11 +247,6 @@ module API
expose
:name
,
:color
expose
:name
,
:color
end
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
class
Compare
<
Grape
::
Entity
expose
:commit
,
using:
Entities
::
RepoCommit
do
|
compare
,
options
|
expose
:commit
,
using:
Entities
::
RepoCommit
do
|
compare
,
options
|
Commit
.
decorate
(
compare
.
commits
).
last
Commit
.
decorate
(
compare
.
commits
).
last
...
...
lib/api/merge_requests.rb
View file @
b60d06eb
...
@@ -75,6 +75,22 @@ module API
...
@@ -75,6 +75,22 @@ module API
present
merge_request
,
with:
Entities
::
MergeRequest
present
merge_request
,
with:
Entities
::
MergeRequest
end
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
# Create MR
#
#
# Parameters:
# Parameters:
...
...
spec/requests/api/merge_requests_spec.rb
View file @
b60d06eb
...
@@ -114,6 +114,19 @@ describe API::API, api: true do
...
@@ -114,6 +114,19 @@ describe API::API, api: true do
end
end
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
describe
"POST /projects/:id/merge_requests"
do
context
'between branches projects'
do
context
'between branches projects'
do
it
"should return merge_request"
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