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:
authorShinya Maeda <shinya@gitlab.com>2018-12-04 10:30:19 +0300
committerShinya Maeda <shinya@gitlab.com>2018-12-04 10:30:19 +0300
commit8b5478494fced2abb965e1fb723044afd4e1734e (patch)
tree4ccd5f5130b547b1af371ae04ceb5dc3ad77d404
parent2b2f93698b4f479d673067caa384b604732852e4 (diff)
Define the default value for only/except policies
-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, 45 insertions, 6 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 4f2ac94b6c3..085be5da08d 100644
--- a/lib/gitlab/ci/config/entry/job.rb
+++ b/lib/gitlab/ci/config/entry/job.rb
@@ -65,10 +65,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..d1e09c98527 100644
--- a/lib/gitlab/ci/config/entry/policy.rb
+++ b/lib/gitlab/ci/config/entry/policy.rb
@@ -5,12 +5,9 @@ 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) }
- strategy :ComplexPolicy, if: -> (config) { config.is_a?(Hash) }
-
class RefsPolicy < ::Gitlab::Config::Entry::Node
include ::Gitlab::Config::Entry::Validatable
@@ -66,6 +63,13 @@ module Gitlab
def self.default
end
+
+ 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