Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/commit_status.rb')
-rw-r--r--app/models/commit_status.rb33
1 files changed, 6 insertions, 27 deletions
diff --git a/app/models/commit_status.rb b/app/models/commit_status.rb
index 524429bf12a..e989129209a 100644
--- a/app/models/commit_status.rb
+++ b/app/models/commit_status.rb
@@ -55,6 +55,8 @@ class CommitStatus < ApplicationRecord
scope :for_ref, -> (ref) { where(ref: ref) }
scope :by_name, -> (name) { where(name: name) }
scope :in_pipelines, ->(pipelines) { where(pipeline: pipelines) }
+ scope :eager_load_pipeline, -> { eager_load(:pipeline, project: { namespace: :route }) }
+ scope :with_pipeline, -> { joins(:pipeline) }
scope :for_project_paths, -> (paths) do
where(project: Project.where_full_path_in(Array(paths)))
@@ -179,14 +181,9 @@ class CommitStatus < ApplicationRecord
end
after_transition any => :failed do |commit_status|
- next unless commit_status.project
-
- # rubocop: disable CodeReuse/ServiceClass
commit_status.run_after_commit do
- MergeRequests::AddTodoWhenBuildFailsService
- .new(project, nil).execute(self)
+ ::Gitlab::Ci::Pipeline::Metrics.job_failure_reason_counter.increment(reason: commit_status.failure_reason)
end
- # rubocop: enable CodeReuse/ServiceClass
end
end
@@ -210,26 +207,7 @@ class CommitStatus < ApplicationRecord
end
def group_name
- simplified_commit_status_group_name_feature_flag = Gitlab::SafeRequestStore.fetch("project:#{project_id}:simplified_commit_status_group_name") do
- Feature.enabled?(:simplified_commit_status_group_name, project, default_enabled: false)
- end
-
- if simplified_commit_status_group_name_feature_flag
- # Only remove one or more [...] "X/Y" "X Y" from the end of build names.
- # More about the regular expression logic: https://docs.gitlab.com/ee/ci/jobs/#group-jobs-in-a-pipeline
-
- name.to_s.sub(%r{([\b\s:]+((\[.*\])|(\d+[\s:\/\\]+\d+)))+\s*\z}, '').strip
- else
- # Prior implementation, remove [...] "X/Y" "X Y" from the beginning and middle of build names
- # 'rspec:linux: 1/10' => 'rspec:linux'
- common_name = name.to_s.gsub(%r{\b\d+[\s:\/\\]+\d+\s*}, '')
-
- # 'rspec:linux: [aws, max memory]' => 'rspec:linux', 'rspec:linux: [aws]' => 'rspec:linux'
- common_name.gsub!(%r{: \[.*\]\s*\z}, '')
-
- common_name.strip!
- common_name
- end
+ name.to_s.sub(%r{([\b\s:]+((\[.*\])|(\d+[\s:\/\\]+\d+)))+\s*\z}, '').strip
end
def failed_but_allowed?
@@ -293,7 +271,8 @@ class CommitStatus < ApplicationRecord
end
def update_older_statuses_retried!
- self.class
+ pipeline
+ .statuses
.latest
.where(name: name)
.where.not(id: id)