diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-04-20 13:00:54 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-04-20 13:00:54 +0300 |
commit | 3cccd102ba543e02725d247893729e5c73b38295 (patch) | |
tree | f36a04ec38517f5deaaacb5acc7d949688d1e187 /app/experiments/ios_specific_templates_experiment.rb | |
parent | 205943281328046ef7b4528031b90fbda70c75ac (diff) |
Add latest changes from gitlab-org/gitlab@14-10-stable-eev14.10.0-rc42
Diffstat (limited to 'app/experiments/ios_specific_templates_experiment.rb')
-rw-r--r-- | app/experiments/ios_specific_templates_experiment.rb | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/app/experiments/ios_specific_templates_experiment.rb b/app/experiments/ios_specific_templates_experiment.rb new file mode 100644 index 00000000000..1731fa87be8 --- /dev/null +++ b/app/experiments/ios_specific_templates_experiment.rb @@ -0,0 +1,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 |