blob: 7377af84e0b4fdd3ad9dba0c91c6fd280cce2128 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# frozen_string_literal: true
class Release < ActiveRecord::Base
include CacheMarkdownField
cache_markdown_field :description
belongs_to :project
# releases prior to 11.7 have no author
belongs_to :author, class_name: 'User'
validates :description, :project, :tag, presence: true
scope :sorted, -> { order(created_at: :desc) }
delegate :repository, to: :project
def self.by_tag(project, tag)
self.find_by(project: project, tag: tag)
end
def commit
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
|