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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
b9aac409
Commit
b9aac409
authored
Dec 21, 2018
by
Alessio Caiazza
Committed by
Shinya Maeda
Dec 31, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Expose assets in releases API
parent
1ea2d9fa
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
0 deletions
+27
-0
app/models/release.rb
app/models/release.rb
+13
-0
lib/api/entities.rb
lib/api/entities.rb
+14
-0
No files found.
app/models/release.rb
View file @
b9aac409
...
...
@@ -17,4 +17,17 @@ class Release < ActiveRecord::Base
git_tag
=
repository
.
find_tag
(
tag
)
repository
.
commit
(
git_tag
.
dereferenced_target
)
end
def
sources_formats
@sources_formats
||=
%w(zip tar.gz tar.bz2 tar)
.
freeze
end
# TODO: placeholder for frontend API compatibility
def
links
[]
end
def
assets_count
links
.
size
+
sources_formats
.
size
end
end
lib/api/entities.rb
View file @
b9aac409
...
...
@@ -1099,6 +1099,20 @@ module API
expose
:created_at
expose
:author
,
using:
Entities
::
UserBasic
,
if:
->
(
release
,
_
)
{
release
.
author
.
present?
}
expose
:commit
,
using:
Entities
::
Commit
expose
:assets
do
expose
:assets_count
,
as: :count
expose
:links
expose
:sources
do
|
release
,
_opts
|
archive_path
=
"
#{
release
.
project
.
path
}
-
#{
release
.
tag
.
tr
(
'/'
,
'-'
)
}
"
release
.
sources_formats
.
map
do
|
format
|
{
format:
format
,
url:
Gitlab
::
Routing
.
url_helpers
.
project_archive_url
(
release
.
project
,
id:
File
.
join
(
release
.
tag
,
archive_path
),
format:
format
)
}
end
end
end
end
class
Tag
<
Grape
::
Entity
...
...
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