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
path: root/lib
diff options
context:
space:
mode:
authorjhampton <jhampton@gitlab.com>2018-12-07 21:21:43 +0300
committerYorick Peterse <yorickpeterse@gmail.com>2018-12-17 18:11:35 +0300
commit071d593dfe486ed71946d379daa5576ccfe21935 (patch)
tree507cd6e9eeb5e91182111d9d39ae38a230db45c8 /lib
parent1b7a8b47f5844d07644ab2fe6239fc45d666d89a (diff)
Merge remote-tracking branch 'origin/master' into 20422-hide-ui-variables-by-default
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/ci/config/entry/except_policy.rb17
-rw-r--r--lib/gitlab/ci/config/entry/job.rb4
-rw-r--r--lib/gitlab/ci/config/entry/only_policy.rb18
-rw-r--r--lib/gitlab/ci/config/entry/policy.rb12
4 files changed, 48 insertions, 3 deletions
diff --git a/lib/gitlab/ci/config/entry/except_policy.rb b/lib/gitlab/ci/config/entry/except_policy.rb
new file mode 100644
index 00000000000..46ded35325d
--- /dev/null
+++ b/lib/gitlab/ci/config/entry/except_policy.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+module Gitlab
+ module Ci
+ class Config
+ module Entry
+ ##
+ # Entry that represents an only/except trigger policy for the job.
+ #
+ class ExceptPolicy < Policy
+ def self.default
+ end
+ end
+ end
+ end
+ end
+end
diff --git a/lib/gitlab/ci/config/entry/job.rb b/lib/gitlab/ci/config/entry/job.rb
index 50942fbdb40..22400798e9e 100644
--- a/lib/gitlab/ci/config/entry/job.rb
+++ b/lib/gitlab/ci/config/entry/job.rb
@@ -72,10 +72,10 @@ module Gitlab
entry :services, Entry::Services,
description: 'Services that will be used to execute this job.'
- entry :only, Entry::Policy,
+ entry :only, Entry::OnlyPolicy,
description: 'Refs policy this job will be executed for.'
- entry :except, Entry::Policy,
+ entry :except, Entry::ExceptPolicy,
description: 'Refs policy this job will be executed for.'
entry :variables, Entry::Variables,
diff --git a/lib/gitlab/ci/config/entry/only_policy.rb b/lib/gitlab/ci/config/entry/only_policy.rb
new file mode 100644
index 00000000000..9a581b8e97e
--- /dev/null
+++ b/lib/gitlab/ci/config/entry/only_policy.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+module Gitlab
+ module Ci
+ class Config
+ module Entry
+ ##
+ # Entry that represents an only/except trigger policy for the job.
+ #
+ class OnlyPolicy < Policy
+ def self.default
+ { refs: %w[branches tags] }
+ end
+ end
+ end
+ end
+ end
+end
diff --git a/lib/gitlab/ci/config/entry/policy.rb b/lib/gitlab/ci/config/entry/policy.rb
index 998da1f6837..d98b60f07d6 100644
--- a/lib/gitlab/ci/config/entry/policy.rb
+++ b/lib/gitlab/ci/config/entry/policy.rb
@@ -5,7 +5,7 @@ module Gitlab
class Config
module Entry
##
- # Entry that represents an only/except trigger policy for the job.
+ # Base class for OnlyPolicy and ExceptPolicy
#
class Policy < ::Gitlab::Config::Entry::Simplifiable
strategy :RefsPolicy, if: -> (config) { config.is_a?(Array) }
@@ -66,6 +66,16 @@ module Gitlab
def self.default
end
+
+ ##
+ # Class-level execution won't be inherited by subclasses by default.
+ # Therefore, we need to explicitly execute that for OnlyPolicy and ExceptPolicy
+ def self.inherited(klass)
+ super
+
+ klass.strategy :RefsPolicy, if: -> (config) { config.is_a?(Array) }
+ klass.strategy :ComplexPolicy, if: -> (config) { config.is_a?(Hash) }
+ end
end
end
end