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
Jérome Perrin
gitlab-ce
Commits
c55a9ac4
Commit
c55a9ac4
authored
Oct 05, 2017
by
Vitaliy @blackst0ne Klachkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove 'Repo' prefix from API entites
parent
8921af39
Changes
16
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
84 additions
and
80 deletions
+84
-80
app/serializers/commit_entity.rb
app/serializers/commit_entity.rb
+1
-1
changelogs/unreleased/remove_repo_prefix_from_api.yml
changelogs/unreleased/remove_repo_prefix_from_api.yml
+5
-0
lib/api/branches.rb
lib/api/branches.rb
+10
-10
lib/api/commits.rb
lib/api/commits.rb
+9
-9
lib/api/entities.rb
lib/api/entities.rb
+21
-22
lib/api/merge_requests.rb
lib/api/merge_requests.rb
+2
-2
lib/api/repositories.rb
lib/api/repositories.rb
+2
-2
lib/api/tags.rb
lib/api/tags.rb
+6
-6
lib/api/templates.rb
lib/api/templates.rb
+4
-4
lib/api/v3/branches.rb
lib/api/v3/branches.rb
+4
-4
lib/api/v3/commits.rb
lib/api/v3/commits.rb
+8
-8
lib/api/v3/entities.rb
lib/api/v3/entities.rb
+2
-2
lib/api/v3/merge_requests.rb
lib/api/v3/merge_requests.rb
+2
-2
lib/api/v3/repositories.rb
lib/api/v3/repositories.rb
+2
-2
lib/api/v3/tags.rb
lib/api/v3/tags.rb
+2
-2
lib/api/v3/templates.rb
lib/api/v3/templates.rb
+4
-4
No files found.
app/serializers/commit_entity.rb
View file @
c55a9ac4
class
CommitEntity
<
API
::
Entities
::
Repo
Commit
class
CommitEntity
<
API
::
Entities
::
Commit
include
RequestAwareEntity
include
RequestAwareEntity
expose
:author
,
using:
UserEntity
expose
:author
,
using:
UserEntity
...
...
changelogs/unreleased/remove_repo_prefix_from_api.yml
0 → 100644
View file @
c55a9ac4
---
title
:
Remove 'Repo' prefix from API entites
merge_request
:
14694
author
:
Vitaliy @blackst0ne Klachkov
type
:
other
lib/api/branches.rb
View file @
c55a9ac4
...
@@ -13,7 +13,7 @@ module API
...
@@ -13,7 +13,7 @@ module API
end
end
resource
:projects
,
requirements:
API
::
PROJECT_ENDPOINT_REQUIREMENTS
do
resource
:projects
,
requirements:
API
::
PROJECT_ENDPOINT_REQUIREMENTS
do
desc
'Get a project repository branches'
do
desc
'Get a project repository branches'
do
success
Entities
::
Repo
Branch
success
Entities
::
Branch
end
end
params
do
params
do
use
:pagination
use
:pagination
...
@@ -23,13 +23,13 @@ module API
...
@@ -23,13 +23,13 @@ module API
# n+1: https://gitlab.com/gitlab-org/gitlab-ce/issues/37442
# n+1: https://gitlab.com/gitlab-org/gitlab-ce/issues/37442
Gitlab
::
GitalyClient
.
allow_n_plus_1_calls
do
Gitlab
::
GitalyClient
.
allow_n_plus_1_calls
do
present
paginate
(
branches
),
with:
Entities
::
Repo
Branch
,
project:
user_project
present
paginate
(
branches
),
with:
Entities
::
Branch
,
project:
user_project
end
end
end
end
resource
':id/repository/branches/:branch'
,
requirements:
BRANCH_ENDPOINT_REQUIREMENTS
do
resource
':id/repository/branches/:branch'
,
requirements:
BRANCH_ENDPOINT_REQUIREMENTS
do
desc
'Get a single branch'
do
desc
'Get a single branch'
do
success
Entities
::
Repo
Branch
success
Entities
::
Branch
end
end
params
do
params
do
requires
:branch
,
type:
String
,
desc:
'The name of the branch'
requires
:branch
,
type:
String
,
desc:
'The name of the branch'
...
@@ -41,7 +41,7 @@ module API
...
@@ -41,7 +41,7 @@ module API
branch
=
user_project
.
repository
.
find_branch
(
params
[
:branch
])
branch
=
user_project
.
repository
.
find_branch
(
params
[
:branch
])
not_found!
(
'Branch'
)
unless
branch
not_found!
(
'Branch'
)
unless
branch
present
branch
,
with:
Entities
::
Repo
Branch
,
project:
user_project
present
branch
,
with:
Entities
::
Branch
,
project:
user_project
end
end
end
end
...
@@ -50,7 +50,7 @@ module API
...
@@ -50,7 +50,7 @@ module API
# in `gitlab-org/gitlab-ce!5081`. The API interface has not been changed (to maintain compatibility),
# in `gitlab-org/gitlab-ce!5081`. The API interface has not been changed (to maintain compatibility),
# but it works with the changed data model to infer `developers_can_merge` and `developers_can_push`.
# but it works with the changed data model to infer `developers_can_merge` and `developers_can_push`.
desc
'Protect a single branch'
do
desc
'Protect a single branch'
do
success
Entities
::
Repo
Branch
success
Entities
::
Branch
end
end
params
do
params
do
requires
:branch
,
type:
String
,
desc:
'The name of the branch'
requires
:branch
,
type:
String
,
desc:
'The name of the branch'
...
@@ -80,7 +80,7 @@ module API
...
@@ -80,7 +80,7 @@ module API
end
end
if
protected_branch
.
valid?
if
protected_branch
.
valid?
present
branch
,
with:
Entities
::
Repo
Branch
,
project:
user_project
present
branch
,
with:
Entities
::
Branch
,
project:
user_project
else
else
render_api_error!
(
protected_branch
.
errors
.
full_messages
,
422
)
render_api_error!
(
protected_branch
.
errors
.
full_messages
,
422
)
end
end
...
@@ -88,7 +88,7 @@ module API
...
@@ -88,7 +88,7 @@ module API
# Note: This API will be deprecated in favor of the protected branches API.
# Note: This API will be deprecated in favor of the protected branches API.
desc
'Unprotect a single branch'
do
desc
'Unprotect a single branch'
do
success
Entities
::
Repo
Branch
success
Entities
::
Branch
end
end
params
do
params
do
requires
:branch
,
type:
String
,
desc:
'The name of the branch'
requires
:branch
,
type:
String
,
desc:
'The name of the branch'
...
@@ -101,11 +101,11 @@ module API
...
@@ -101,11 +101,11 @@ module API
protected_branch
=
user_project
.
protected_branches
.
find_by
(
name:
branch
.
name
)
protected_branch
=
user_project
.
protected_branches
.
find_by
(
name:
branch
.
name
)
protected_branch
&
.
destroy
protected_branch
&
.
destroy
present
branch
,
with:
Entities
::
Repo
Branch
,
project:
user_project
present
branch
,
with:
Entities
::
Branch
,
project:
user_project
end
end
desc
'Create branch'
do
desc
'Create branch'
do
success
Entities
::
Repo
Branch
success
Entities
::
Branch
end
end
params
do
params
do
requires
:branch
,
type:
String
,
desc:
'The name of the branch'
requires
:branch
,
type:
String
,
desc:
'The name of the branch'
...
@@ -119,7 +119,7 @@ module API
...
@@ -119,7 +119,7 @@ module API
if
result
[
:status
]
==
:success
if
result
[
:status
]
==
:success
present
result
[
:branch
],
present
result
[
:branch
],
with:
Entities
::
Repo
Branch
,
with:
Entities
::
Branch
,
project:
user_project
project:
user_project
else
else
render_api_error!
(
result
[
:message
],
400
)
render_api_error!
(
result
[
:message
],
400
)
...
...
lib/api/commits.rb
View file @
c55a9ac4
...
@@ -13,7 +13,7 @@ module API
...
@@ -13,7 +13,7 @@ module API
end
end
resource
:projects
,
requirements:
API
::
PROJECT_ENDPOINT_REQUIREMENTS
do
resource
:projects
,
requirements:
API
::
PROJECT_ENDPOINT_REQUIREMENTS
do
desc
'Get a project repository commits'
do
desc
'Get a project repository commits'
do
success
Entities
::
Repo
Commit
success
Entities
::
Commit
end
end
params
do
params
do
optional
:ref_name
,
type:
String
,
desc:
'The name of a repository branch or tag, if not given the default branch is used'
optional
:ref_name
,
type:
String
,
desc:
'The name of a repository branch or tag, if not given the default branch is used'
...
@@ -46,11 +46,11 @@ module API
...
@@ -46,11 +46,11 @@ module API
paginated_commits
=
Kaminari
.
paginate_array
(
commits
,
total_count:
commit_count
)
paginated_commits
=
Kaminari
.
paginate_array
(
commits
,
total_count:
commit_count
)
present
paginate
(
paginated_commits
),
with:
Entities
::
Repo
Commit
present
paginate
(
paginated_commits
),
with:
Entities
::
Commit
end
end
desc
'Commit multiple file changes as one commit'
do
desc
'Commit multiple file changes as one commit'
do
success
Entities
::
Repo
CommitDetail
success
Entities
::
CommitDetail
detail
'This feature was introduced in GitLab 8.13'
detail
'This feature was introduced in GitLab 8.13'
end
end
params
do
params
do
...
@@ -72,14 +72,14 @@ module API
...
@@ -72,14 +72,14 @@ module API
if
result
[
:status
]
==
:success
if
result
[
:status
]
==
:success
commit_detail
=
user_project
.
repository
.
commit
(
result
[
:result
])
commit_detail
=
user_project
.
repository
.
commit
(
result
[
:result
])
present
commit_detail
,
with:
Entities
::
Repo
CommitDetail
present
commit_detail
,
with:
Entities
::
CommitDetail
else
else
render_api_error!
(
result
[
:message
],
400
)
render_api_error!
(
result
[
:message
],
400
)
end
end
end
end
desc
'Get a specific commit of a project'
do
desc
'Get a specific commit of a project'
do
success
Entities
::
Repo
CommitDetail
success
Entities
::
CommitDetail
failure
[[
404
,
'Commit Not Found'
]]
failure
[[
404
,
'Commit Not Found'
]]
end
end
params
do
params
do
...
@@ -90,7 +90,7 @@ module API
...
@@ -90,7 +90,7 @@ module API
not_found!
'Commit'
unless
commit
not_found!
'Commit'
unless
commit
present
commit
,
with:
Entities
::
Repo
CommitDetail
present
commit
,
with:
Entities
::
CommitDetail
end
end
desc
'Get the diff for a specific commit of a project'
do
desc
'Get the diff for a specific commit of a project'
do
...
@@ -104,7 +104,7 @@ module API
...
@@ -104,7 +104,7 @@ module API
not_found!
'Commit'
unless
commit
not_found!
'Commit'
unless
commit
present
commit
.
raw_diffs
.
to_a
,
with:
Entities
::
Repo
Diff
present
commit
.
raw_diffs
.
to_a
,
with:
Entities
::
Diff
end
end
desc
"Get a commit's comments"
do
desc
"Get a commit's comments"
do
...
@@ -126,7 +126,7 @@ module API
...
@@ -126,7 +126,7 @@ module API
desc
'Cherry pick commit into a branch'
do
desc
'Cherry pick commit into a branch'
do
detail
'This feature was introduced in GitLab 8.15'
detail
'This feature was introduced in GitLab 8.15'
success
Entities
::
Repo
Commit
success
Entities
::
Commit
end
end
params
do
params
do
requires
:sha
,
type:
String
,
desc:
'A commit sha, or the name of a branch or tag to be cherry picked'
requires
:sha
,
type:
String
,
desc:
'A commit sha, or the name of a branch or tag to be cherry picked'
...
@@ -151,7 +151,7 @@ module API
...
@@ -151,7 +151,7 @@ module API
if
result
[
:status
]
==
:success
if
result
[
:status
]
==
:success
branch
=
user_project
.
repository
.
find_branch
(
params
[
:branch
])
branch
=
user_project
.
repository
.
find_branch
(
params
[
:branch
])
present
user_project
.
repository
.
commit
(
branch
.
dereferenced_target
),
with:
Entities
::
Repo
Commit
present
user_project
.
repository
.
commit
(
branch
.
dereferenced_target
),
with:
Entities
::
Commit
else
else
render_api_error!
(
result
[
:message
],
400
)
render_api_error!
(
result
[
:message
],
400
)
end
end
...
...
lib/api/entities.rb
View file @
c55a9ac4
...
@@ -220,7 +220,7 @@ module API
...
@@ -220,7 +220,7 @@ module API
expose
:shared_projects
,
using:
Entities
::
Project
expose
:shared_projects
,
using:
Entities
::
Project
end
end
class
Repo
Commit
<
Grape
::
Entity
class
Commit
<
Grape
::
Entity
expose
:id
,
:short_id
,
:title
,
:created_at
expose
:id
,
:short_id
,
:title
,
:created_at
expose
:parent_ids
expose
:parent_ids
expose
:safe_message
,
as: :message
expose
:safe_message
,
as: :message
...
@@ -228,20 +228,20 @@ module API
...
@@ -228,20 +228,20 @@ module API
expose
:committer_name
,
:committer_email
,
:committed_date
expose
:committer_name
,
:committer_email
,
:committed_date
end
end
class
Repo
CommitStats
<
Grape
::
Entity
class
CommitStats
<
Grape
::
Entity
expose
:additions
,
:deletions
,
:total
expose
:additions
,
:deletions
,
:total
end
end
class
RepoCommitDetail
<
Repo
Commit
class
CommitDetail
<
Commit
expose
:stats
,
using:
Entities
::
Repo
CommitStats
expose
:stats
,
using:
Entities
::
CommitStats
expose
:status
expose
:status
expose
:last_pipeline
,
using:
'API::Entities::PipelineBasic'
expose
:last_pipeline
,
using:
'API::Entities::PipelineBasic'
end
end
class
Repo
Branch
<
Grape
::
Entity
class
Branch
<
Grape
::
Entity
expose
:name
expose
:name
expose
:commit
,
using:
Entities
::
Repo
Commit
do
|
repo_branch
,
options
|
expose
:commit
,
using:
Entities
::
Commit
do
|
repo_branch
,
options
|
options
[
:project
].
repository
.
commit
(
repo_branch
.
dereferenced_target
)
options
[
:project
].
repository
.
commit
(
repo_branch
.
dereferenced_target
)
end
end
...
@@ -265,7 +265,7 @@ module API
...
@@ -265,7 +265,7 @@ module API
end
end
end
end
class
Repo
TreeObject
<
Grape
::
Entity
class
TreeObject
<
Grape
::
Entity
expose
:id
,
:name
,
:type
,
:path
expose
:id
,
:name
,
:type
,
:path
expose
:mode
do
|
obj
,
options
|
expose
:mode
do
|
obj
,
options
|
...
@@ -305,7 +305,7 @@ module API
...
@@ -305,7 +305,7 @@ module API
expose
:state
,
:created_at
,
:updated_at
expose
:state
,
:created_at
,
:updated_at
end
end
class
Repo
Diff
<
Grape
::
Entity
class
Diff
<
Grape
::
Entity
expose
:old_path
,
:new_path
,
:a_mode
,
:b_mode
expose
:old_path
,
:new_path
,
:a_mode
,
:b_mode
expose
:new_file?
,
as: :new_file
expose
:new_file?
,
as: :new_file
expose
:renamed_file?
,
as: :renamed_file
expose
:renamed_file?
,
as: :renamed_file
...
@@ -483,7 +483,7 @@ module API
...
@@ -483,7 +483,7 @@ module API
end
end
class
MergeRequestChanges
<
MergeRequest
class
MergeRequestChanges
<
MergeRequest
expose
:diffs
,
as: :changes
,
using:
Entities
::
Repo
Diff
do
|
compare
,
_
|
expose
:diffs
,
as: :changes
,
using:
Entities
::
Diff
do
|
compare
,
_
|
compare
.
raw_diffs
(
limits:
false
).
to_a
compare
.
raw_diffs
(
limits:
false
).
to_a
end
end
end
end
...
@@ -494,9 +494,9 @@ module API
...
@@ -494,9 +494,9 @@ module API
end
end
class
MergeRequestDiffFull
<
MergeRequestDiff
class
MergeRequestDiffFull
<
MergeRequestDiff
expose
:commits
,
using:
Entities
::
Repo
Commit
expose
:commits
,
using:
Entities
::
Commit
expose
:diffs
,
using:
Entities
::
Repo
Diff
do
|
compare
,
_
|
expose
:diffs
,
using:
Entities
::
Diff
do
|
compare
,
_
|
compare
.
raw_diffs
(
limits:
false
).
to_a
compare
.
raw_diffs
(
limits:
false
).
to_a
end
end
end
end
...
@@ -592,8 +592,7 @@ module API
...
@@ -592,8 +592,7 @@ module API
expose
:target_type
expose
:target_type
expose
:target
do
|
todo
,
options
|
expose
:target
do
|
todo
,
options
|
target
=
todo
.
target_type
==
'Commit'
?
'RepoCommit'
:
todo
.
target_type
Entities
.
const_get
(
todo
.
target_type
).
represent
(
todo
.
target
,
options
)
Entities
.
const_get
(
target
).
represent
(
todo
.
target
,
options
)
end
end
expose
:target_url
do
|
todo
,
options
|
expose
:target_url
do
|
todo
,
options
|
...
@@ -729,15 +728,15 @@ module API
...
@@ -729,15 +728,15 @@ module API
end
end
class
Compare
<
Grape
::
Entity
class
Compare
<
Grape
::
Entity
expose
:commit
,
using:
Entities
::
Repo
Commit
do
|
compare
,
options
|
expose
:commit
,
using:
Entities
::
Commit
do
|
compare
,
options
|
Commit
.
decorate
(
compare
.
commits
,
nil
).
last
::
Commit
.
decorate
(
compare
.
commits
,
nil
).
last
end
end
expose
:commits
,
using:
Entities
::
Repo
Commit
do
|
compare
,
options
|
expose
:commits
,
using:
Entities
::
Commit
do
|
compare
,
options
|
Commit
.
decorate
(
compare
.
commits
,
nil
)
::
Commit
.
decorate
(
compare
.
commits
,
nil
)
end
end
expose
:diffs
,
using:
Entities
::
Repo
Diff
do
|
compare
,
options
|
expose
:diffs
,
using:
Entities
::
Diff
do
|
compare
,
options
|
compare
.
diffs
(
limits:
false
).
to_a
compare
.
diffs
(
limits:
false
).
to_a
end
end
...
@@ -773,10 +772,10 @@ module API
...
@@ -773,10 +772,10 @@ module API
expose
:description
expose
:description
end
end
class
Repo
Tag
<
Grape
::
Entity
class
Tag
<
Grape
::
Entity
expose
:name
,
:message
expose
:name
,
:message
expose
:commit
,
using:
Entities
::
Repo
Commit
do
|
repo_tag
,
options
|
expose
:commit
,
using:
Entities
::
Commit
do
|
repo_tag
,
options
|
options
[
:project
].
repository
.
commit
(
repo_tag
.
dereferenced_target
)
options
[
:project
].
repository
.
commit
(
repo_tag
.
dereferenced_target
)
end
end
...
@@ -827,7 +826,7 @@ module API
...
@@ -827,7 +826,7 @@ module API
expose
:created_at
,
:started_at
,
:finished_at
expose
:created_at
,
:started_at
,
:finished_at
expose
:user
,
with:
User
expose
:user
,
with:
User
expose
:artifacts_file
,
using:
JobArtifactFile
,
if:
->
(
job
,
opts
)
{
job
.
artifacts?
}
expose
:artifacts_file
,
using:
JobArtifactFile
,
if:
->
(
job
,
opts
)
{
job
.
artifacts?
}
expose
:commit
,
with:
Repo
Commit
expose
:commit
,
with:
Commit
expose
:runner
,
with:
Runner
expose
:runner
,
with:
Runner
expose
:pipeline
,
with:
PipelineBasic
expose
:pipeline
,
with:
PipelineBasic
end
end
...
@@ -880,7 +879,7 @@ module API
...
@@ -880,7 +879,7 @@ module API
expose
:deployable
,
using:
Entities
::
Job
expose
:deployable
,
using:
Entities
::
Job
end
end
class
Repo
License
<
Grape
::
Entity
class
License
<
Grape
::
Entity
expose
:key
,
:name
,
:nickname
expose
:key
,
:name
,
:nickname
expose
:featured
,
as: :popular
expose
:featured
,
as: :popular
expose
:url
,
as: :html_url
expose
:url
,
as: :html_url
...
...
lib/api/merge_requests.rb
View file @
c55a9ac4
...
@@ -183,13 +183,13 @@ module API
...
@@ -183,13 +183,13 @@ module API
end
end
desc
'Get the commits of a merge request'
do
desc
'Get the commits of a merge request'
do
success
Entities
::
Repo
Commit
success
Entities
::
Commit
end
end
get
':id/merge_requests/:merge_request_iid/commits'
do
get
':id/merge_requests/:merge_request_iid/commits'
do
merge_request
=
find_merge_request_with_access
(
params
[
:merge_request_iid
])
merge_request
=
find_merge_request_with_access
(
params
[
:merge_request_iid
])
commits
=
::
Kaminari
.
paginate_array
(
merge_request
.
commits
)
commits
=
::
Kaminari
.
paginate_array
(
merge_request
.
commits
)
present
paginate
(
commits
),
with:
Entities
::
Repo
Commit
present
paginate
(
commits
),
with:
Entities
::
Commit
end
end
desc
'Show the merge request changes'
do
desc
'Show the merge request changes'
do
...
...
lib/api/repositories.rb
View file @
c55a9ac4
...
@@ -35,7 +35,7 @@ module API
...
@@ -35,7 +35,7 @@ module API
end
end
desc
'Get a project repository tree'
do
desc
'Get a project repository tree'
do
success
Entities
::
Repo
TreeObject
success
Entities
::
TreeObject
end
end
params
do
params
do
optional
:ref
,
type:
String
,
desc:
'The name of a repository branch or tag, if not given the default branch is used'
optional
:ref
,
type:
String
,
desc:
'The name of a repository branch or tag, if not given the default branch is used'
...
@@ -52,7 +52,7 @@ module API
...
@@ -52,7 +52,7 @@ module API
tree
=
user_project
.
repository
.
tree
(
commit
.
id
,
path
,
recursive:
params
[
:recursive
])
tree
=
user_project
.
repository
.
tree
(
commit
.
id
,
path
,
recursive:
params
[
:recursive
])
entries
=
::
Kaminari
.
paginate_array
(
tree
.
sorted_entries
)
entries
=
::
Kaminari
.
paginate_array
(
tree
.
sorted_entries
)
present
paginate
(
entries
),
with:
Entities
::
Repo
TreeObject
present
paginate
(
entries
),
with:
Entities
::
TreeObject
end
end
desc
'Get raw blob contents from the repository'
desc
'Get raw blob contents from the repository'
...
...
lib/api/tags.rb
View file @
c55a9ac4
...
@@ -11,18 +11,18 @@ module API
...
@@ -11,18 +11,18 @@ module API
end
end
resource
:projects
,
requirements:
API
::
PROJECT_ENDPOINT_REQUIREMENTS
do
resource
:projects
,
requirements:
API
::
PROJECT_ENDPOINT_REQUIREMENTS
do
desc
'Get a project repository tags'
do
desc
'Get a project repository tags'
do
success
Entities
::
Repo
Tag
success
Entities
::
Tag
end
end
params
do
params
do
use
:pagination
use
:pagination
end
end
get
':id/repository/tags'
do
get
':id/repository/tags'
do
tags
=
::
Kaminari
.
paginate_array
(
user_project
.
repository
.
tags
.
sort_by
(
&
:name
).
reverse
)
tags
=
::
Kaminari
.
paginate_array
(
user_project
.
repository
.
tags
.
sort_by
(
&
:name
).
reverse
)
present
paginate
(
tags
),
with:
Entities
::
Repo
Tag
,
project:
user_project
present
paginate
(
tags
),
with:
Entities
::
Tag
,
project:
user_project
end
end
desc
'Get a single repository tag'
do
desc
'Get a single repository tag'
do
success
Entities
::
Repo
Tag
success
Entities
::
Tag
end
end
params
do
params
do
requires
:tag_name
,
type:
String
,
desc:
'The name of the tag'
requires
:tag_name
,
type:
String
,
desc:
'The name of the tag'
...
@@ -31,11 +31,11 @@ module API
...
@@ -31,11 +31,11 @@ module API
tag
=
user_project
.
repository
.
find_tag
(
params
[
:tag_name
])
tag
=
user_project
.
repository
.
find_tag
(
params
[
:tag_name
])
not_found!
(
'Tag'
)
unless
tag
not_found!
(
'Tag'
)
unless
tag
present
tag
,
with:
Entities
::
Repo
Tag
,
project:
user_project
present
tag
,
with:
Entities
::
Tag
,
project:
user_project
end
end
desc
'Create a new repository tag'
do
desc
'Create a new repository tag'
do
success
Entities
::
Repo
Tag
success
Entities
::
Tag
end
end
params
do
params
do
requires
:tag_name
,
type:
String
,
desc:
'The name of the tag'
requires
:tag_name
,
type:
String
,
desc:
'The name of the tag'
...
@@ -51,7 +51,7 @@ module API
...
@@ -51,7 +51,7 @@ module API
if
result
[
:status
]
==
:success
if
result
[
:status
]
==
:success
present
result
[
:tag
],
present
result
[
:tag
],
with:
Entities
::
Repo
Tag
,
with:
Entities
::
Tag
,
project:
user_project
project:
user_project
else
else
render_api_error!
(
result
[
:message
],
400
)
render_api_error!
(
result
[
:message
],
400
)
...
...
lib/api/templates.rb
View file @
c55a9ac4
...
@@ -49,7 +49,7 @@ module API
...
@@ -49,7 +49,7 @@ module API
desc
'Get the list of the available license template'
do
desc
'Get the list of the available license template'
do
detail
'This feature was introduced in GitLab 8.7.'
detail
'This feature was introduced in GitLab 8.7.'
success
::
API
::
Entities
::
Repo
License
success
::
API
::
Entities
::
License
end
end
params
do
params
do
optional
:popular
,
type:
Boolean
,
desc:
'If passed, returns only popular licenses'
optional
:popular
,
type:
Boolean
,
desc:
'If passed, returns only popular licenses'
...
@@ -60,12 +60,12 @@ module API
...
@@ -60,12 +60,12 @@ module API
featured:
declared
(
params
)[
:popular
].
present?
?
true
:
nil
featured:
declared
(
params
)[
:popular
].
present?
?
true
:
nil
}
}
licences
=
::
Kaminari
.
paginate_array
(
Licensee
::
License
.
all
(
options
))
licences
=
::
Kaminari
.
paginate_array
(
Licensee
::
License
.
all
(
options
))
present
paginate
(
licences
),
with:
Entities
::
Repo
License
present
paginate
(
licences
),
with:
Entities
::
License
end
end
desc
'Get the text for a specific license'
do
desc
'Get the text for a specific license'
do
detail
'This feature was introduced in GitLab 8.7.'
detail
'This feature was introduced in GitLab 8.7.'
success
::
API
::
Entities
::
Repo
License
success
::
API
::
Entities
::
License
end
end
params
do
params
do
requires
:name
,
type:
String
,
desc:
'The name of the template'
requires
:name
,
type:
String
,
desc:
'The name of the template'
...
@@ -75,7 +75,7 @@ module API
...
@@ -75,7 +75,7 @@ module API
template
=
parsed_license_template
template
=
parsed_license_template
present
template
,
with:
::
API
::
Entities
::
Repo
License
present
template
,
with:
::
API
::
Entities
::
License
end
end
GLOBAL_TEMPLATE_TYPES
.
each
do
|
template_type
,
properties
|
GLOBAL_TEMPLATE_TYPES
.
each
do
|
template_type
,
properties
|
...
...
lib/api/v3/branches.rb
View file @
c55a9ac4
...
@@ -11,12 +11,12 @@ module API
...
@@ -11,12 +11,12 @@ module API
end
end
resource
:projects
,
requirements:
{
id:
%r{[^/]+}
}
do
resource
:projects
,
requirements:
{
id:
%r{[^/]+}
}
do
desc
'Get a project repository branches'
do
desc
'Get a project repository branches'
do
success
::
API
::
Entities
::
Repo
Branch
success
::
API
::
Entities
::
Branch
end
end
get
":id/repository/branches"
do
get
":id/repository/branches"
do
branches
=
user_project
.
repository
.
branches
.
sort_by
(
&
:name
)
branches
=
user_project
.
repository
.
branches
.
sort_by
(
&
:name
)
present
branches
,
with:
::
API
::
Entities
::
Repo
Branch
,
project:
user_project
present
branches
,
with:
::
API
::
Entities
::
Branch
,
project:
user_project
end
end
desc
'Delete a branch'
desc
'Delete a branch'
...
@@ -47,7 +47,7 @@ module API
...
@@ -47,7 +47,7 @@ module API
end
end
desc
'Create branch'
do
desc
'Create branch'
do
success
::
API
::
Entities
::
Repo
Branch
success
::
API
::
Entities
::
Branch
end
end
params
do
params
do
requires
:branch_name
,
type:
String
,
desc:
'The name of the branch'
requires
:branch_name
,
type:
String
,
desc:
'The name of the branch'
...
@@ -60,7 +60,7 @@ module API
...
@@ -60,7 +60,7 @@ module API
if
result
[
:status
]
==
:success
if
result
[
:status
]
==
:success
present
result
[
:branch
],
present
result
[
:branch
],
with:
::
API
::
Entities
::
Repo
Branch
,
with:
::
API
::
Entities
::
Branch
,
project:
user_project
project:
user_project
else
else
render_api_error!
(
result
[
:message
],
400
)
render_api_error!
(
result
[
:message
],
400
)
...
...
lib/api/v3/commits.rb
View file @
c55a9ac4
...
@@ -13,7 +13,7 @@ module API
...
@@ -13,7 +13,7 @@ module API
end
end
resource
:projects
,
requirements:
{
id:
%r{[^/]+}
}
do
resource
:projects
,
requirements:
{
id:
%r{[^/]+}
}
do
desc
'Get a project repository commits'
do
desc
'Get a project repository commits'
do
success
::
API
::
Entities
::
Repo
Commit
success
::
API
::
Entities
::
Commit
end
end
params
do
params
do
optional
:ref_name
,
type:
String
,
desc:
'The name of a repository branch or tag, if not given the default branch is used'
optional
:ref_name
,
type:
String
,
desc:
'The name of a repository branch or tag, if not given the default branch is used'
...
@@ -34,11 +34,11 @@ module API
...
@@ -34,11 +34,11 @@ module API
after:
params
[
:since
],
after:
params
[
:since
],
before:
params
[
:until
])
before:
params
[
:until
])
present
commits
,
with:
::
API
::
Entities
::
Repo
Commit
present
commits
,
with:
::
API
::
Entities
::
Commit
end
end
desc
'Commit multiple file changes as one commit'
do
desc
'Commit multiple file changes as one commit'
do
success
::
API
::
Entities
::
Repo
CommitDetail
success
::
API
::
Entities
::
CommitDetail
detail
'This feature was introduced in GitLab 8.13'
detail
'This feature was introduced in GitLab 8.13'
end
end
params
do
params
do
...
@@ -59,14 +59,14 @@ module API
...
@@ -59,14 +59,14 @@ module API
if
result
[
:status
]
==
:success
if
result
[
:status
]
==
:success
commit_detail
=
user_project
.
repository
.
commits
(
result
[
:result
],
limit:
1
).
first
commit_detail
=
user_project
.
repository
.
commits
(
result
[
:result
],
limit:
1
).
first
present
commit_detail
,
with:
::
API
::
Entities
::
Repo
CommitDetail
present
commit_detail
,
with:
::
API
::
Entities
::
CommitDetail
else
else
render_api_error!
(
result
[
:message
],
400
)
render_api_error!
(
result
[
:message
],
400
)
end
end
end
end
desc
'Get a specific commit of a project'
do
desc
'Get a specific commit of a project'
do
success
::
API
::
Entities
::
Repo
CommitDetail
success
::
API
::
Entities
::
CommitDetail
failure
[[
404
,
'Not Found'
]]
failure
[[
404
,
'Not Found'
]]
end
end
params
do
params
do
...
@@ -77,7 +77,7 @@ module API
...
@@ -77,7 +77,7 @@ module API
not_found!
"Commit"
unless
commit
not_found!
"Commit"
unless
commit
present
commit
,
with:
::
API
::
Entities
::
Repo
CommitDetail
present
commit
,
with:
::
API
::
Entities
::
CommitDetail
end
end
desc
'Get the diff for a specific commit of a project'
do
desc
'Get the diff for a specific commit of a project'
do
...
@@ -113,7 +113,7 @@ module API
...
@@ -113,7 +113,7 @@ module API
desc
'Cherry pick commit into a branch'
do
desc
'Cherry pick commit into a branch'
do
detail
'This feature was introduced in GitLab 8.15'
detail
'This feature was introduced in GitLab 8.15'
success
::
API
::
Entities
::
Repo
Commit
success
::
API
::
Entities
::
Commit
end
end
params
do
params
do
requires
:sha
,
type:
String
,
desc:
'A commit sha to be cherry picked'
requires
:sha
,
type:
String
,
desc:
'A commit sha to be cherry picked'
...
@@ -138,7 +138,7 @@ module API
...
@@ -138,7 +138,7 @@ module API
if
result
[
:status
]
==
:success
if
result
[
:status
]
==
:success
branch
=
user_project
.
repository
.
find_branch
(
params
[
:branch
])
branch
=
user_project
.
repository
.
find_branch
(
params
[
:branch
])
present
user_project
.
repository
.
commit
(
branch
.
dereferenced_target
),
with:
::
API
::
Entities
::
Repo
Commit
present
user_project
.
repository
.
commit
(
branch
.
dereferenced_target
),
with:
::
API
::
Entities
::
Commit
else
else
render_api_error!
(
result
[
:message
],
400
)
render_api_error!
(
result
[
:message
],
400
)
end
end
...
...
lib/api/v3/entities.rb
View file @
c55a9ac4
...
@@ -220,7 +220,7 @@ module API
...
@@ -220,7 +220,7 @@ module API
expose
:created_at
,
:started_at
,
:finished_at
expose
:created_at
,
:started_at
,
:finished_at
expose
:user
,
with:
::
API
::
Entities
::
User
expose
:user
,
with:
::
API
::
Entities
::
User
expose
:artifacts_file
,
using:
::
API
::
Entities
::
JobArtifactFile
,
if:
->
(
build
,
opts
)
{
build
.
artifacts?
}
expose
:artifacts_file
,
using:
::
API
::
Entities
::
JobArtifactFile
,
if:
->
(
build
,
opts
)
{
build
.
artifacts?
}
expose
:commit
,
with:
::
API
::
Entities
::
Repo
Commit
expose
:commit
,
with:
::
API
::
Entities
::
Commit
expose
:runner
,
with:
::
API
::
Entities
::
Runner
expose
:runner
,
with:
::
API
::
Entities
::
Runner
expose
:pipeline
,
with:
::
API
::
Entities
::
PipelineBasic
expose
:pipeline
,
with:
::
API
::
Entities
::
PipelineBasic
end
end
...
@@ -237,7 +237,7 @@ module API
...
@@ -237,7 +237,7 @@ module API
end
end
class
MergeRequestChanges
<
MergeRequest
class
MergeRequestChanges
<
MergeRequest
expose
:diffs
,
as: :changes
,
using:
::
API
::
Entities
::
Repo
Diff
do
|
compare
,
_
|
expose
:diffs
,
as: :changes
,
using:
::
API
::
Entities
::
Diff
do
|
compare
,
_
|
compare
.
raw_diffs
(
limits:
false
).
to_a
compare
.
raw_diffs
(
limits:
false
).
to_a
end
end
end
end
...
...
lib/api/v3/merge_requests.rb
View file @
c55a9ac4
...
@@ -135,12 +135,12 @@ module API
...
@@ -135,12 +135,12 @@ module API
end
end
desc
'Get the commits of a merge request'
do
desc
'Get the commits of a merge request'
do
success
::
API
::
Entities
::
Repo
Commit
success
::
API
::
Entities
::
Commit
end
end
get
"
#{
path
}
/commits"
do
get
"
#{
path
}
/commits"
do
merge_request
=
find_merge_request_with_access
(
params
[
:merge_request_id
])
merge_request
=
find_merge_request_with_access
(
params
[
:merge_request_id
])
present
merge_request
.
commits
,
with:
::
API
::
Entities
::
Repo
Commit
present
merge_request
.
commits
,
with:
::
API
::
Entities
::
Commit
end
end
desc
'Show the merge request changes'
do
desc
'Show the merge request changes'
do
...
...
lib/api/v3/repositories.rb
View file @
c55a9ac4
...
@@ -19,7 +19,7 @@ module API
...
@@ -19,7 +19,7 @@ module API
end
end
desc
'Get a project repository tree'
do
desc
'Get a project repository tree'
do
success
::
API
::
Entities
::
Repo
TreeObject
success
::
API
::
Entities
::
TreeObject
end
end
params
do
params
do
optional
:ref_name
,
type:
String
,
desc:
'The name of a repository branch or tag, if not given the default branch is used'
optional
:ref_name
,
type:
String
,
desc:
'The name of a repository branch or tag, if not given the default branch is used'
...
@@ -35,7 +35,7 @@ module API
...
@@ -35,7 +35,7 @@ module API
tree
=
user_project
.
repository
.
tree
(
commit
.
id
,
path
,
recursive:
params
[
:recursive
])
tree
=
user_project
.
repository
.
tree
(
commit
.
id
,
path
,
recursive:
params
[
:recursive
])
present
tree
.
sorted_entries
,
with:
::
API
::
Entities
::
Repo
TreeObject
present
tree
.
sorted_entries
,
with:
::
API
::
Entities
::
TreeObject
end
end
desc
'Get a raw file contents'
desc
'Get a raw file contents'
...
...
lib/api/v3/tags.rb
View file @
c55a9ac4
...
@@ -8,11 +8,11 @@ module API
...
@@ -8,11 +8,11 @@ module API
end
end
resource
:projects
,
requirements:
{
id:
%r{[^/]+}
}
do
resource
:projects
,
requirements:
{
id:
%r{[^/]+}
}
do
desc
'Get a project repository tags'
do
desc
'Get a project repository tags'
do
success
::
API
::
Entities
::
Repo
Tag
success
::
API
::
Entities
::
Tag
end
end
get
":id/repository/tags"
do
get
":id/repository/tags"
do
tags
=
user_project
.
repository
.
tags
.
sort_by
(
&
:name
).
reverse
tags
=
user_project
.
repository
.
tags
.
sort_by
(
&
:name
).
reverse
present
tags
,
with:
::
API
::
Entities
::
Repo
Tag
,
project:
user_project
present
tags
,
with:
::
API
::
Entities
::
Tag
,
project:
user_project
end
end
desc
'Delete a repository tag'
desc
'Delete a repository tag'
...
...
lib/api/v3/templates.rb
View file @
c55a9ac4
...
@@ -52,7 +52,7 @@ module API
...
@@ -52,7 +52,7 @@ module API
detailed_desc
=
'This feature was introduced in GitLab 8.7.'
detailed_desc
=
'This feature was introduced in GitLab 8.7.'
detailed_desc
<<
DEPRECATION_MESSAGE
unless
status
==
:ok
detailed_desc
<<
DEPRECATION_MESSAGE
unless
status
==
:ok
detail
detailed_desc
detail
detailed_desc
success
::
API
::
Entities
::
Repo
License
success
::
API
::
Entities
::
License
end
end
params
do
params
do
optional
:popular
,
type:
Boolean
,
desc:
'If passed, returns only popular licenses'
optional
:popular
,
type:
Boolean
,
desc:
'If passed, returns only popular licenses'
...
@@ -61,7 +61,7 @@ module API
...
@@ -61,7 +61,7 @@ module API
options
=
{
options
=
{
featured:
declared
(
params
)[
:popular
].
present?
?
true
:
nil
featured:
declared
(
params
)[
:popular
].
present?
?
true
:
nil
}
}
present
Licensee
::
License
.
all
(
options
),
with:
::
API
::
Entities
::
Repo
License
present
Licensee
::
License
.
all
(
options
),
with:
::
API
::
Entities
::
License
end
end
end
end
...
@@ -70,7 +70,7 @@ module API
...
@@ -70,7 +70,7 @@ module API
detailed_desc
=
'This feature was introduced in GitLab 8.7.'
detailed_desc
=
'This feature was introduced in GitLab 8.7.'
detailed_desc
<<
DEPRECATION_MESSAGE
unless
status
==
:ok
detailed_desc
<<
DEPRECATION_MESSAGE
unless
status
==
:ok
detail
detailed_desc
detail
detailed_desc
success
::
API
::
Entities
::
Repo
License
success
::
API
::
Entities
::
License
end
end
params
do
params
do
requires
:name
,
type:
String
,
desc:
'The name of the template'
requires
:name
,
type:
String
,
desc:
'The name of the template'
...
@@ -80,7 +80,7 @@ module API
...
@@ -80,7 +80,7 @@ module API
template
=
parsed_license_template
template
=
parsed_license_template
present
template
,
with:
::
API
::
Entities
::
Repo
License
present
template
,
with:
::
API
::
Entities
::
License
end
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