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
309aee45
Commit
309aee45
authored
Oct 27, 2016
by
Ben Boeckel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
entities: use the RepoCommit entity for branch commits
Fixes #23895.
parent
e5f446b7
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
74 additions
and
26 deletions
+74
-26
changelogs/unreleased/api-entities.yml
changelogs/unreleased/api-entities.yml
+4
-0
doc/api/branches.md
doc/api/branches.md
+10
-0
doc/api/commits.md
doc/api/commits.md
+15
-3
lib/api/entities.rb
lib/api/entities.rb
+18
-17
spec/requests/api/branches_spec.rb
spec/requests/api/branches_spec.rb
+12
-1
spec/requests/api/commits_spec.rb
spec/requests/api/commits_spec.rb
+15
-5
No files found.
changelogs/unreleased/api-entities.yml
0 → 100644
View file @
309aee45
---
title
:
"
Use
an
entity
for
RepoBranch
commits
and
enhance
RepoCommit"
merge_request
:
7138
author
:
Ben Boeckel
doc/api/branches.md
View file @
309aee45
...
@@ -34,6 +34,8 @@ Example response:
...
@@ -34,6 +34,8 @@ Example response:
"committer_email"
:
"john@example.com"
,
"committer_email"
:
"john@example.com"
,
"committer_name"
:
"John Smith"
,
"committer_name"
:
"John Smith"
,
"id"
:
"7b5c3cc8be40ee161ae89a06bba6229da1032a0c"
,
"id"
:
"7b5c3cc8be40ee161ae89a06bba6229da1032a0c"
,
"short_id"
:
"7b5c3cc"
,
"title"
:
"add projects API"
,
"message"
:
"add projects API"
,
"message"
:
"add projects API"
,
"parent_ids"
:
[
"parent_ids"
:
[
"4ad91d3c1144c406e50c7b33bae684bd6837faf8"
"4ad91d3c1144c406e50c7b33bae684bd6837faf8"
...
@@ -78,6 +80,8 @@ Example response:
...
@@ -78,6 +80,8 @@ Example response:
"committer_email"
:
"john@example.com"
,
"committer_email"
:
"john@example.com"
,
"committer_name"
:
"John Smith"
,
"committer_name"
:
"John Smith"
,
"id"
:
"7b5c3cc8be40ee161ae89a06bba6229da1032a0c"
,
"id"
:
"7b5c3cc8be40ee161ae89a06bba6229da1032a0c"
,
"short_id"
:
"7b5c3cc"
,
"title"
:
"add projects API"
,
"message"
:
"add projects API"
,
"message"
:
"add projects API"
,
"parent_ids"
:
[
"parent_ids"
:
[
"4ad91d3c1144c406e50c7b33bae684bd6837faf8"
"4ad91d3c1144c406e50c7b33bae684bd6837faf8"
...
@@ -119,6 +123,8 @@ Example response:
...
@@ -119,6 +123,8 @@ Example response:
"committer_email"
:
"john@example.com"
,
"committer_email"
:
"john@example.com"
,
"committer_name"
:
"John Smith"
,
"committer_name"
:
"John Smith"
,
"id"
:
"7b5c3cc8be40ee161ae89a06bba6229da1032a0c"
,
"id"
:
"7b5c3cc8be40ee161ae89a06bba6229da1032a0c"
,
"short_id"
:
"7b5c3cc"
,
"title"
:
"add projects API"
,
"message"
:
"add projects API"
,
"message"
:
"add projects API"
,
"parent_ids"
:
[
"parent_ids"
:
[
"4ad91d3c1144c406e50c7b33bae684bd6837faf8"
"4ad91d3c1144c406e50c7b33bae684bd6837faf8"
...
@@ -163,6 +169,8 @@ Example response:
...
@@ -163,6 +169,8 @@ Example response:
"committer_email"
:
"john@example.com"
,
"committer_email"
:
"john@example.com"
,
"committer_name"
:
"John Smith"
,
"committer_name"
:
"John Smith"
,
"id"
:
"7b5c3cc8be40ee161ae89a06bba6229da1032a0c"
,
"id"
:
"7b5c3cc8be40ee161ae89a06bba6229da1032a0c"
,
"short_id"
:
"7b5c3cc"
,
"title"
:
"add projects API"
,
"message"
:
"add projects API"
,
"message"
:
"add projects API"
,
"parent_ids"
:
[
"parent_ids"
:
[
"4ad91d3c1144c406e50c7b33bae684bd6837faf8"
"4ad91d3c1144c406e50c7b33bae684bd6837faf8"
...
@@ -204,6 +212,8 @@ Example response:
...
@@ -204,6 +212,8 @@ Example response:
"committer_email"
:
"john@example.com"
,
"committer_email"
:
"john@example.com"
,
"committer_name"
:
"John Smith"
,
"committer_name"
:
"John Smith"
,
"id"
:
"7b5c3cc8be40ee161ae89a06bba6229da1032a0c"
,
"id"
:
"7b5c3cc8be40ee161ae89a06bba6229da1032a0c"
,
"short_id"
:
"7b5c3cc"
,
"title"
:
"add projects API"
,
"message"
:
"add projects API"
,
"message"
:
"add projects API"
,
"parent_ids"
:
[
"parent_ids"
:
[
"4ad91d3c1144c406e50c7b33bae684bd6837faf8"
"4ad91d3c1144c406e50c7b33bae684bd6837faf8"
...
...
doc/api/commits.md
View file @
309aee45
...
@@ -29,11 +29,15 @@ Example response:
...
@@ -29,11 +29,15 @@ Example response:
"title"
:
"Replace sanitize with escape once"
,
"title"
:
"Replace sanitize with escape once"
,
"author_name"
:
"Dmitriy Zaporozhets"
,
"author_name"
:
"Dmitriy Zaporozhets"
,
"author_email"
:
"dzaporozhets@sphereconsultinginc.com"
,
"author_email"
:
"dzaporozhets@sphereconsultinginc.com"
,
"authored_date"
:
"2012-09-20T11:50:22+03:00"
,
"committer_name"
:
"Administrator"
,
"committer_name"
:
"Administrator"
,
"committer_email"
:
"admin@example.com"
,
"committer_email"
:
"admin@example.com"
,
"committed_date"
:
"2012-09-20T11:50:22+03:00"
,
"created_at"
:
"2012-09-20T11:50:22+03:00"
,
"created_at"
:
"2012-09-20T11:50:22+03:00"
,
"message"
:
"Replace sanitize with escape once"
,
"message"
:
"Replace sanitize with escape once"
,
"allow_failure"
:
false
"parent_ids"
:
[
"6104942438c14ec7bd21c6cd5bd995272b3faff6"
]
},
},
{
{
"id"
:
"6104942438c14ec7bd21c6cd5bd995272b3faff6"
,
"id"
:
"6104942438c14ec7bd21c6cd5bd995272b3faff6"
,
...
@@ -45,7 +49,9 @@ Example response:
...
@@ -45,7 +49,9 @@ Example response:
"committer_email"
:
"dmitriy.zaporozhets@gmail.com"
,
"committer_email"
:
"dmitriy.zaporozhets@gmail.com"
,
"created_at"
:
"2012-09-20T09:06:12+03:00"
,
"created_at"
:
"2012-09-20T09:06:12+03:00"
,
"message"
:
"Sanitize for network graph"
,
"message"
:
"Sanitize for network graph"
,
"allow_failure"
:
false
"parent_ids"
:
[
"ae1d9fb46aa2b07ee9836d49862ec4e2c46fbbba"
]
}
}
]
]
```
```
...
@@ -214,10 +220,16 @@ Example response:
...
@@ -214,10 +220,16 @@ Example response:
"title"
:
"Feature added"
,
"title"
:
"Feature added"
,
"author_name"
:
"Dmitriy Zaporozhets"
,
"author_name"
:
"Dmitriy Zaporozhets"
,
"author_email"
:
"dmitriy.zaporozhets@gmail.com"
,
"author_email"
:
"dmitriy.zaporozhets@gmail.com"
,
"authored_date"
:
"2016-12-12T20:10:39.000+01:00"
,
"created_at"
:
"2016-12-12T20:10:39.000+01:00"
,
"created_at"
:
"2016-12-12T20:10:39.000+01:00"
,
"committer_name"
:
"Administrator"
,
"committer_name"
:
"Administrator"
,
"committer_email"
:
"admin@example.com"
,
"committer_email"
:
"admin@example.com"
,
"message"
:
"Feature added
\n\n
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
\n
"
"committed_date"
:
"2016-12-12T20:10:39.000+01:00"
,
"title"
:
"Feature added"
,
"message"
:
"Feature added
\n\n
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
\n
"
,
"parent_ids"
:
[
"a738f717824ff53aebad8b090c1b79a14f2bd9e8"
]
}
}
```
```
...
...
lib/api/entities.rb
View file @
309aee45
...
@@ -155,10 +155,27 @@ module API
...
@@ -155,10 +155,27 @@ module API
expose
:shared_projects
,
using:
Entities
::
Project
expose
:shared_projects
,
using:
Entities
::
Project
end
end
class
RepoCommit
<
Grape
::
Entity
expose
:id
,
:short_id
,
:title
,
:created_at
expose
:parent_ids
expose
:safe_message
,
as: :message
expose
:author_name
,
:author_email
,
:authored_date
expose
:committer_name
,
:committer_email
,
:committed_date
end
class
RepoCommitStats
<
Grape
::
Entity
expose
:additions
,
:deletions
,
:total
end
class
RepoCommitDetail
<
RepoCommit
expose
:stats
,
using:
Entities
::
RepoCommitStats
expose
:status
end
class
RepoBranch
<
Grape
::
Entity
class
RepoBranch
<
Grape
::
Entity
expose
:name
expose
:name
expose
:commit
do
|
repo_branch
,
options
|
expose
:commit
,
using:
Entities
::
RepoCommit
do
|
repo_branch
,
options
|
options
[
:project
].
repository
.
commit
(
repo_branch
.
dereferenced_target
)
options
[
:project
].
repository
.
commit
(
repo_branch
.
dereferenced_target
)
end
end
...
@@ -193,22 +210,6 @@ module API
...
@@ -193,22 +210,6 @@ module API
end
end
end
end
class
RepoCommit
<
Grape
::
Entity
expose
:id
,
:short_id
,
:title
,
:author_name
,
:author_email
,
:created_at
expose
:committer_name
,
:committer_email
expose
:safe_message
,
as: :message
end
class
RepoCommitStats
<
Grape
::
Entity
expose
:additions
,
:deletions
,
:total
end
class
RepoCommitDetail
<
RepoCommit
expose
:parent_ids
,
:committed_date
,
:authored_date
expose
:stats
,
using:
Entities
::
RepoCommitStats
expose
:status
end
class
ProjectSnippet
<
Grape
::
Entity
class
ProjectSnippet
<
Grape
::
Entity
expose
:id
,
:title
,
:file_name
expose
:id
,
:title
,
:file_name
expose
:author
,
using:
Entities
::
UserBasic
expose
:author
,
using:
Entities
::
UserBasic
...
...
spec/requests/api/branches_spec.rb
View file @
309aee45
...
@@ -31,7 +31,18 @@ describe API::Branches, api: true do
...
@@ -31,7 +31,18 @@ describe API::Branches, api: true do
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
json_response
[
'name'
]).
to
eq
(
branch_name
)
expect
(
json_response
[
'name'
]).
to
eq
(
branch_name
)
expect
(
json_response
[
'commit'
][
'id'
]).
to
eq
(
branch_sha
)
json_commit
=
json_response
[
'commit'
]
expect
(
json_commit
[
'id'
]).
to
eq
(
branch_sha
)
expect
(
json_commit
).
to
have_key
(
'short_id'
)
expect
(
json_commit
).
to
have_key
(
'title'
)
expect
(
json_commit
).
to
have_key
(
'message'
)
expect
(
json_commit
).
to
have_key
(
'author_name'
)
expect
(
json_commit
).
to
have_key
(
'author_email'
)
expect
(
json_commit
).
to
have_key
(
'authored_date'
)
expect
(
json_commit
).
to
have_key
(
'committer_name'
)
expect
(
json_commit
).
to
have_key
(
'committer_email'
)
expect
(
json_commit
).
to
have_key
(
'committed_date'
)
expect
(
json_commit
).
to
have_key
(
'parent_ids'
)
expect
(
json_response
[
'merged'
]).
to
eq
(
false
)
expect
(
json_response
[
'merged'
]).
to
eq
(
false
)
expect
(
json_response
[
'protected'
]).
to
eq
(
false
)
expect
(
json_response
[
'protected'
]).
to
eq
(
false
)
expect
(
json_response
[
'developers_can_push'
]).
to
eq
(
false
)
expect
(
json_response
[
'developers_can_push'
]).
to
eq
(
false
)
...
...
spec/requests/api/commits_spec.rb
View file @
309aee45
...
@@ -367,11 +367,21 @@ describe API::Commits, api: true do
...
@@ -367,11 +367,21 @@ describe API::Commits, api: true do
get
api
(
"/projects/
#{
project
.
id
}
/repository/commits/
#{
project
.
repository
.
commit
.
id
}
"
,
user
)
get
api
(
"/projects/
#{
project
.
id
}
/repository/commits/
#{
project
.
repository
.
commit
.
id
}
"
,
user
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
json_response
[
'id'
]).
to
eq
(
project
.
repository
.
commit
.
id
)
commit
=
project
.
repository
.
commit
expect
(
json_response
[
'title'
]).
to
eq
(
project
.
repository
.
commit
.
title
)
expect
(
json_response
[
'id'
]).
to
eq
(
commit
.
id
)
expect
(
json_response
[
'stats'
][
'additions'
]).
to
eq
(
project
.
repository
.
commit
.
stats
.
additions
)
expect
(
json_response
[
'short_id'
]).
to
eq
(
commit
.
short_id
)
expect
(
json_response
[
'stats'
][
'deletions'
]).
to
eq
(
project
.
repository
.
commit
.
stats
.
deletions
)
expect
(
json_response
[
'title'
]).
to
eq
(
commit
.
title
)
expect
(
json_response
[
'stats'
][
'total'
]).
to
eq
(
project
.
repository
.
commit
.
stats
.
total
)
expect
(
json_response
[
'message'
]).
to
eq
(
commit
.
safe_message
)
expect
(
json_response
[
'author_name'
]).
to
eq
(
commit
.
author_name
)
expect
(
json_response
[
'author_email'
]).
to
eq
(
commit
.
author_email
)
expect
(
json_response
[
'authored_date'
]).
to
eq
(
commit
.
authored_date
.
iso8601
(
3
))
expect
(
json_response
[
'committer_name'
]).
to
eq
(
commit
.
committer_name
)
expect
(
json_response
[
'committer_email'
]).
to
eq
(
commit
.
committer_email
)
expect
(
json_response
[
'committed_date'
]).
to
eq
(
commit
.
committed_date
.
iso8601
(
3
))
expect
(
json_response
[
'parent_ids'
]).
to
eq
(
commit
.
parent_ids
)
expect
(
json_response
[
'stats'
][
'additions'
]).
to
eq
(
commit
.
stats
.
additions
)
expect
(
json_response
[
'stats'
][
'deletions'
]).
to
eq
(
commit
.
stats
.
deletions
)
expect
(
json_response
[
'stats'
][
'total'
]).
to
eq
(
commit
.
stats
.
total
)
end
end
it
"returns a 404 error if not found"
do
it
"returns a 404 error if not found"
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