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
95198907
Commit
95198907
authored
Jan 21, 2019
by
Robert Schilling
Committed by
Rémy Coutable
Jan 21, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Search project tags via API
parent
764f2678
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
25 additions
and
2 deletions
+25
-2
changelogs/unreleased/api-tags-search.yml
changelogs/unreleased/api-tags-search.yml
+5
-0
doc/api/tags.md
doc/api/tags.md
+3
-0
lib/api/tags.rb
lib/api/tags.rb
+5
-2
spec/requests/api/tags_spec.rb
spec/requests/api/tags_spec.rb
+12
-0
No files found.
changelogs/unreleased/api-tags-search.yml
0 → 100644
View file @
95198907
---
title
:
'
API:
Support
searching
for
tags'
merge_request
:
24385
author
:
Robert Schilling
type
:
added
doc/api/tags.md
View file @
95198907
...
@@ -17,6 +17,9 @@ Parameters:
...
@@ -17,6 +17,9 @@ Parameters:
|
`id`
| integer/string| yes | The ID or
[
URL-encoded path of the project
](
README.md#namespaced-path-encoding
)
owned by the authenticated user|
|
`id`
| integer/string| yes | The ID or
[
URL-encoded path of the project
](
README.md#namespaced-path-encoding
)
owned by the authenticated user|
|
`order_by`
| string | no | Return tags ordered by
`name`
or
`updated`
fields. Default is
`updated`
|
|
`order_by`
| string | no | Return tags ordered by
`name`
or
`updated`
fields. Default is
`updated`
|
|
`sort`
| string | no | Return tags sorted in
`asc`
or
`desc`
order. Default is
`desc`
|
|
`sort`
| string | no | Return tags sorted in
`asc`
or
`desc`
order. Default is
`desc`
|
|
`search`
| string | no | Return list of tags matching the search criteria |
> Support for `search` was [introduced](https://gitlab.com/gitlab-org/gitlab-ce/issues/54401) in GitLab 11.8.
```
json
```
json
[
[
...
...
lib/api/tags.rb
View file @
95198907
...
@@ -20,12 +20,15 @@ module API
...
@@ -20,12 +20,15 @@ module API
desc:
'Return tags sorted in updated by `asc` or `desc` order.'
desc:
'Return tags sorted in updated by `asc` or `desc` order.'
optional
:order_by
,
type:
String
,
values:
%w[name updated]
,
default:
'updated'
,
optional
:order_by
,
type:
String
,
values:
%w[name updated]
,
default:
'updated'
,
desc:
'Return tags ordered by `name` or `updated` fields.'
desc:
'Return tags ordered by `name` or `updated` fields.'
optional
:search
,
type:
String
,
desc:
'Return list of tags matching the search criteria'
use
:pagination
use
:pagination
end
end
get
':id/repository/tags'
do
get
':id/repository/tags'
do
tags
=
::
Kaminari
.
paginate_array
(
::
TagsFinder
.
new
(
user_project
.
repository
,
sort:
"
#{
params
[
:order_by
]
}
_
#{
params
[
:sort
]
}
"
).
execute
)
tags
=
::
TagsFinder
.
new
(
user_project
.
repository
,
sort:
"
#{
params
[
:order_by
]
}
_
#{
params
[
:sort
]
}
"
,
search:
params
[
:search
]).
execute
present
paginate
(
tags
),
with:
Entities
::
Tag
,
project:
user_project
present
paginate
(
::
Kaminari
.
paginate_array
(
tags
)
),
with:
Entities
::
Tag
,
project:
user_project
end
end
desc
'Get a single repository tag'
do
desc
'Get a single repository tag'
do
...
...
spec/requests/api/tags_spec.rb
View file @
95198907
...
@@ -54,6 +54,18 @@ describe API::Tags do
...
@@ -54,6 +54,18 @@ describe API::Tags do
end
end
end
end
context
'searching'
do
it
'only returns searched tags'
do
get
api
(
"
#{
route
}
"
,
user
),
params:
{
search:
'v1.1.0'
}
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
size
).
to
eq
(
1
)
expect
(
json_response
[
0
][
'name'
]).
to
eq
(
'v1.1.0'
)
end
end
shared_examples_for
'repository tags'
do
shared_examples_for
'repository tags'
do
it
'returns the repository tags'
do
it
'returns the repository tags'
do
get
api
(
route
,
current_user
)
get
api
(
route
,
current_user
)
...
...
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