debian-mirror-gitlab/app/experiments/ios_specific_templates_experiment.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

31 lines
807 B
Ruby
Raw Normal View History

2022-06-21 17:19:12 +05:30
# frozen_string_literal: true
class IosSpecificTemplatesExperiment < ApplicationExperiment
before_run(if: :skip_experiment) { throw(:abort) } # rubocop:disable Cop/BanCatchThrow
private
def skip_experiment
actor_not_able_to_create_pipelines? ||
project_targets_non_ios_platforms? ||
project_has_gitlab_ci? ||
project_has_pipelines?
end
def actor_not_able_to_create_pipelines?
!context.actor.is_a?(User) || !context.actor.can?(:create_pipeline, context.project)
end
def project_targets_non_ios_platforms?
context.project.project_setting.target_platforms.exclude?('ios')
end
def project_has_gitlab_ci?
context.project.has_ci? && context.project.builds_enabled?
end
def project_has_pipelines?
context.project.all_pipelines.count > 0
end
end