diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-04-14 21:08:29 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-04-14 21:08:29 +0300 |
commit | f55c9253556dd5dab700d76fa88aa04891343100 (patch) | |
tree | b8a6bcc093304acd38c53f7fa2a6be35708c1003 /app/experiments | |
parent | 9b762f50fee09b50b97b5ab208a9a62522447c8c (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/experiments')
-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 |