diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-10 18:07:43 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-10 18:07:43 +0000 |
commit | 6f0f893bd87535b61e0ecb1ce069eaa7fcb9e5be (patch) | |
tree | 8af92b29c838e9af2fd70f9a4a2314a08f4af922 /app/models | |
parent | 8b1228b0d409d7751f01d9fb72ebfbbf62399486 (diff) | |
download | gitlab-ce-6f0f893bd87535b61e0ecb1ce069eaa7fcb9e5be.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/ci/bridge.rb | 3 | ||||
-rw-r--r-- | app/models/ci/build.rb | 3 | ||||
-rw-r--r-- | app/models/ci/pipeline.rb | 3 | ||||
-rw-r--r-- | app/models/ci/processable.rb | 33 | ||||
-rw-r--r-- | app/models/commit_status.rb | 1 | ||||
-rw-r--r-- | app/models/concerns/ci/processable.rb | 41 | ||||
-rw-r--r-- | app/models/error_tracking/project_error_tracking_setting.rb | 19 | ||||
-rw-r--r-- | app/models/release.rb | 4 |
8 files changed, 56 insertions, 51 deletions
diff --git a/app/models/ci/bridge.rb b/app/models/ci/bridge.rb index 6c51f650b6a..804e01bfab0 100644 --- a/app/models/ci/bridge.rb +++ b/app/models/ci/bridge.rb @@ -1,8 +1,7 @@ # frozen_string_literal: true module Ci - class Bridge < CommitStatus - include Ci::Processable + class Bridge < Ci::Processable include Ci::Contextable include Ci::PipelineDelegator include Importable diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb index 5edd2f52fc8..2df41bc2a07 100644 --- a/app/models/ci/build.rb +++ b/app/models/ci/build.rb @@ -1,8 +1,7 @@ # frozen_string_literal: true module Ci - class Build < CommitStatus - include Ci::Processable + class Build < Ci::Processable include Ci::Metadatable include Ci::Contextable include Ci::PipelineDelegator diff --git a/app/models/ci/pipeline.rb b/app/models/ci/pipeline.rb index ab0a4fd6289..7a48fa8595b 100644 --- a/app/models/ci/pipeline.rb +++ b/app/models/ci/pipeline.rb @@ -33,8 +33,7 @@ module Ci has_many :stages, -> { order(position: :asc) }, inverse_of: :pipeline has_many :statuses, class_name: 'CommitStatus', foreign_key: :commit_id, inverse_of: :pipeline has_many :latest_statuses_ordered_by_stage, -> { latest.order(:stage_idx, :stage) }, class_name: 'CommitStatus', foreign_key: :commit_id, inverse_of: :pipeline - has_many :processables, -> { processables }, - class_name: 'CommitStatus', foreign_key: :commit_id, inverse_of: :pipeline + has_many :processables, class_name: 'Ci::Processable', foreign_key: :commit_id, inverse_of: :pipeline has_many :builds, foreign_key: :commit_id, inverse_of: :pipeline has_many :trigger_requests, dependent: :destroy, foreign_key: :commit_id # rubocop:disable Cop/ActiveRecordDependent has_many :variables, class_name: 'Ci::PipelineVariable' diff --git a/app/models/ci/processable.rb b/app/models/ci/processable.rb new file mode 100644 index 00000000000..9c56aa67e20 --- /dev/null +++ b/app/models/ci/processable.rb @@ -0,0 +1,33 @@ +# frozen_string_literal: true + +module Ci + class Processable < ::CommitStatus + has_many :needs, class_name: 'Ci::BuildNeed', foreign_key: :build_id, inverse_of: :build + + accepts_nested_attributes_for :needs + + scope :preload_needs, -> { preload(:needs) } + + validates :type, presence: true + + def schedulable? + raise NotImplementedError + end + + def action? + raise NotImplementedError + end + + def when + read_attribute(:when) || 'on_success' + end + + def expanded_environment_name + raise NotImplementedError + end + + def scoped_variables_hash + raise NotImplementedError + end + end +end diff --git a/app/models/commit_status.rb b/app/models/commit_status.rb index 9da49b44cbe..773481da5f9 100644 --- a/app/models/commit_status.rb +++ b/app/models/commit_status.rb @@ -45,7 +45,6 @@ class CommitStatus < ApplicationRecord scope :before_stage, -> (index) { where('stage_idx < ?', index) } scope :for_stage, -> (index) { where(stage_idx: index) } scope :after_stage, -> (index) { where('stage_idx > ?', index) } - scope :processables, -> { where(type: %w[Ci::Build Ci::Bridge]) } scope :for_ids, -> (ids) { where(id: ids) } scope :for_ref, -> (ref) { where(ref: ref) } scope :by_name, -> (name) { where(name: name) } diff --git a/app/models/concerns/ci/processable.rb b/app/models/concerns/ci/processable.rb deleted file mode 100644 index c229358ad17..00000000000 --- a/app/models/concerns/ci/processable.rb +++ /dev/null @@ -1,41 +0,0 @@ -# frozen_string_literal: true - -module Ci - ## - # This module implements methods that need to be implemented by CI/CD - # entities that are supposed to go through pipeline processing - # services. - # - # - module Processable - extend ActiveSupport::Concern - - included do - has_many :needs, class_name: 'Ci::BuildNeed', foreign_key: :build_id, inverse_of: :build - - accepts_nested_attributes_for :needs - - scope :preload_needs, -> { preload(:needs) } - end - - def schedulable? - raise NotImplementedError - end - - def action? - raise NotImplementedError - end - - def when - read_attribute(:when) || 'on_success' - end - - def expanded_environment_name - raise NotImplementedError - end - - def scoped_variables_hash - raise NotImplementedError - end - end -end diff --git a/app/models/error_tracking/project_error_tracking_setting.rb b/app/models/error_tracking/project_error_tracking_setting.rb index 4aba70cb124..bf7e0e9580a 100644 --- a/app/models/error_tracking/project_error_tracking_setting.rb +++ b/app/models/error_tracking/project_error_tracking_setting.rb @@ -113,9 +113,8 @@ module ErrorTracking when 'list_issues' sentry_client.list_issues(**opts.symbolize_keys) when 'issue_details' - { - issue: sentry_client.issue_details(**opts.symbolize_keys) - } + issue = sentry_client.issue_details(**opts.symbolize_keys) + { issue: add_gitlab_issue_details(issue) } when 'issue_latest_event' { latest_event: sentry_client.issue_latest_event(**opts.symbolize_keys) @@ -140,6 +139,20 @@ module ErrorTracking private + def add_gitlab_issue_details(issue) + issue.gitlab_commit = match_gitlab_commit(issue.first_release_version) + + issue + end + + def match_gitlab_commit(release_version) + return unless release_version + + commit = project.repository.commit(release_version) + + commit&.id + end + def handle_exceptions yield rescue Sentry::Client::Error => e diff --git a/app/models/release.rb b/app/models/release.rb index 4fac64689ab..823fd61eebd 100644 --- a/app/models/release.rb +++ b/app/models/release.rb @@ -81,6 +81,10 @@ class Release < ApplicationRecord evidence&.summary || {} end + def milestone_titles + self.milestones.map {|m| m.title }.sort.join(", ") + end + private def actual_sha |