Class: Release

Inherits:
ApplicationRecord show all
Includes:
CacheMarkdownField, EachBatch, FromUnion, Gitlab::Utils::StrongMemoize, Importable, Presentable
Defined in:
app/models/release.rb

Constant Summary collapse

MAX_NUMBER_TO_DISPLAY =
3

Constants included from CacheMarkdownField

CacheMarkdownField::INVALIDATED_BY

Constants inherited from ApplicationRecord

ApplicationRecord::MAX_PLUCK

Instance Attribute Summary

Attributes included from Importable

#imported, #importing

Instance Method Summary collapse

Methods included from Gitlab::Utils::StrongMemoize

#clear_memoization, #strong_memoize, #strong_memoized?

Methods included from CacheMarkdownField

#attribute_invalidated?, #banzai_render_context, #cached_html_for, #cached_html_up_to_date?, #can_cache_field?, #invalidated_markdown_cache?, #latest_cached_markdown_version, #local_version, #mentionable_attributes_changed?, #parent_user, #refresh_markdown_cache, #refresh_markdown_cache!, #rendered_field_content, #skip_project_check?, #store_mentions!, #updated_cached_html_for

Methods included from Presentable

#present

Methods inherited from ApplicationRecord

cached_column_list, #create_or_load_association, declarative_enum, default_select_columns, id_in, id_not_in, iid_in, pluck_primary_key, primary_key_in, #readable_by?, safe_ensure_unique, safe_find_or_create_by, safe_find_or_create_by!, #to_ability_name, underscore, where_exists, where_not_exists, with_fast_read_statement_timeout, without_order

Methods included from SensitiveSerializableHash

#serializable_hash

Instance Method Details

#assets_count(except: []) ⇒ Object


70
71
72
73
74
75
# File 'app/models/release.rb', line 70

def assets_count(except: [])
  links_count = links.size
  sources_count = except.include?(:sources) ? 0 : sources.size

  links_count + sources_count
end

#commitObject


60
61
62
63
64
# File 'app/models/release.rb', line 60

def commit
  strong_memoize(:commit) do
    repository.commit(actual_sha)
  end
end

#execute_hooks(action) ⇒ Object


103
104
105
106
# File 'app/models/release.rb', line 103

def execute_hooks(action)
  hook_data = to_hook_data(action)
  project.execute_hooks(hook_data, :release_hooks)
end

#historical_release?Boolean

Returns:

  • (Boolean)

87
88
89
# File 'app/models/release.rb', line 87

def historical_release?
  released_at.present? && released_at.to_i < created_at.to_i
end

#milestone_titlesObject


95
96
97
# File 'app/models/release.rb', line 95

def milestone_titles
  self.milestones.order_by_dates_and_title.map {|m| m.title }.join(', ')
end

#nameObject


91
92
93
# File 'app/models/release.rb', line 91

def name
  self.read_attribute(:name) || tag
end

#sourcesObject


77
78
79
80
81
# File 'app/models/release.rb', line 77

def sources
  strong_memoize(:sources) do
    Releases::Source.all(project, tag)
  end
end

#tag_missing?Boolean

Returns:

  • (Boolean)

66
67
68
# File 'app/models/release.rb', line 66

def tag_missing?
  actual_tag.nil?
end

#to_hook_data(action) ⇒ Object


99
100
101
# File 'app/models/release.rb', line 99

def to_hook_data(action)
  Gitlab::HookData::ReleaseBuilder.new(self).build(action)
end

#to_paramObject


56
57
58
# File 'app/models/release.rb', line 56

def to_param
  CGI.escape(tag)
end

#upcoming_release?Boolean

Returns:

  • (Boolean)

83
84
85
# File 'app/models/release.rb', line 83

def upcoming_release?
  released_at.present? && released_at.to_i > Time.zone.now.to_i
end