2018-07-25 09:30:33 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2015-11-05 10:03:02 +00:00
|
|
|
class Release < ActiveRecord::Base
|
2016-10-06 21:17:11 +00:00
|
|
|
include CacheMarkdownField
|
|
|
|
|
|
|
|
cache_markdown_field :description
|
|
|
|
|
2015-11-06 14:29:04 +00:00
|
|
|
belongs_to :project
|
2018-12-13 11:08:53 +00:00
|
|
|
# releases prior to 11.7 have no author
|
2018-12-12 09:56:43 +00:00
|
|
|
belongs_to :author, class_name: 'User'
|
2015-11-06 14:29:04 +00:00
|
|
|
|
2015-11-09 14:30:50 +00:00
|
|
|
validates :description, :project, :tag, presence: true
|
2018-12-13 11:08:53 +00:00
|
|
|
|
|
|
|
delegate :repository, to: :project
|
|
|
|
|
|
|
|
def commit
|
|
|
|
git_tag = repository.find_tag(tag)
|
|
|
|
repository.commit(git_tag.dereferenced_target)
|
|
|
|
end
|
2015-11-05 10:03:02 +00:00
|
|
|
end
|