Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
87fe50f2
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
87fe50f2
编写于
6月 08, 2016
作者:
G
Grzegorz Bizon
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Delegate Ci config entry value to single method
上级
cba266aa
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
48 addition
and
25 deletion
+48
-25
lib/gitlab/ci/config/node/before_script.rb
lib/gitlab/ci/config/node/before_script.rb
+1
-3
lib/gitlab/ci/config/node/entry.rb
lib/gitlab/ci/config/node/entry.rb
+24
-10
lib/gitlab/ci/config/node/global.rb
lib/gitlab/ci/config/node/global.rb
+0
-4
lib/gitlab/ci/config/node/null.rb
lib/gitlab/ci/config/node/null.rb
+7
-0
spec/lib/gitlab/ci/config/node/before_script_spec.rb
spec/lib/gitlab/ci/config/node/before_script_spec.rb
+2
-8
spec/lib/gitlab/ci/config/node/global_spec.rb
spec/lib/gitlab/ci/config/node/global_spec.rb
+8
-0
spec/lib/gitlab/ci/config/node/null_spec.rb
spec/lib/gitlab/ci/config/node/null_spec.rb
+6
-0
未找到文件。
lib/gitlab/ci/config/node/before_script.rb
浏览文件 @
87fe50f2
...
...
@@ -9,9 +9,7 @@ module Gitlab
'Script that is executed before the one defined in a job.'
end
def
script
raise
unless
valid?
def
value
@value
.
join
(
"
\n
"
)
end
...
...
lib/gitlab/ci/config/node/entry.rb
浏览文件 @
87fe50f2
...
...
@@ -3,17 +3,14 @@ module Gitlab
class
Config
module
Node
class
Entry
attr_reader
:value
,
:nodes
,
:parent
class
InvalidError
<
StandardError
;
end
def
initialize
(
value
,
root
=
nil
,
parent
=
nil
)
@value
=
value
@root
=
root
@parent
=
parent
@nodes
,
@errors
=
[],
[]
keys
.
each_key
do
|
key
|
instance_variable_set
(
"@
#{
key
}
"
,
Null
.
new
(
nil
,
root
,
self
))
end
@nodes
=
{}
@errors
=
[]
unless
leaf?
||
value
.
is_a?
(
Hash
)
@errors
<<
'should be a configuration entry with hash value'
...
...
@@ -24,17 +21,23 @@ module Gitlab
return
if
leaf?
||
!
valid?
keys
.
each
do
|
key
,
entry_class
|
next
unless
@value
.
has_key?
(
key
)
if
@value
.
has_key?
(
key
)
entry
=
entry_class
.
new
(
@value
[
key
],
@root
,
self
)
else
entry
=
Node
::
Null
.
new
(
nil
,
@root
,
self
)
end
entry
=
entry_class
.
new
(
@value
[
key
],
@root
,
self
)
instance_variable_set
(
"@
#{
key
}
"
,
entry
)
@nodes
.
append
(
entry
)
@nodes
[
key
]
=
entry
end
nodes
.
each
(
&
:process!
)
nodes
.
each
(
&
:validate!
)
end
def
nodes
@nodes
.
values
end
def
errors
@errors
+
nodes
.
map
(
&
:errors
).
flatten
end
...
...
@@ -51,6 +54,17 @@ module Gitlab
self
.
class
.
nodes
||
{}
end
def
method_missing
(
name
,
*
args
)
super
unless
keys
.
has_key?
(
name
)
raise
InvalidError
unless
valid?
@nodes
[
name
].
value
end
def
value
raise
NotImplementedError
end
def
validate!
raise
NotImplementedError
end
...
...
lib/gitlab/ci/config/node/global.rb
浏览文件 @
87fe50f2
...
...
@@ -4,10 +4,6 @@ module Gitlab
module
Node
class
Global
<
Entry
add_node
:before_script
,
BeforeScript
def
before_script
@before_script
.
script
end
end
end
end
...
...
lib/gitlab/ci/config/node/null.rb
浏览文件 @
87fe50f2
...
...
@@ -3,6 +3,13 @@ module Gitlab
class
Config
module
Node
class
Null
<
Entry
def
value
nil
end
def
validate!
end
def
method_missing
(
*
)
nil
end
...
...
spec/lib/gitlab/ci/config/node/before_script_spec.rb
浏览文件 @
87fe50f2
...
...
@@ -7,9 +7,9 @@ describe Gitlab::Ci::Config::Node::BeforeScript do
context
'when entry value is correct'
do
let
(
:value
)
{
[
'ls'
,
'pwd'
]
}
describe
'#
script
'
do
describe
'#
value
'
do
it
'returns concatenated command'
do
expect
(
entry
.
script
).
to
eq
"ls
\n
pwd"
expect
(
entry
.
value
).
to
eq
"ls
\n
pwd"
end
end
...
...
@@ -29,11 +29,5 @@ describe Gitlab::Ci::Config::Node::BeforeScript do
.
to
include
/should be an array of strings/
end
end
describe
'#script'
do
it
'raises error'
do
expect
{
entry
.
script
}.
to
raise_error
end
end
end
end
spec/lib/gitlab/ci/config/node/global_spec.rb
浏览文件 @
87fe50f2
...
...
@@ -65,6 +65,14 @@ describe Gitlab::Ci::Config::Node::Global do
.
to
include
'before_script should be an array of strings'
end
end
describe
'#before_script'
do
it
'raises error'
do
expect
{
global
.
before_script
}.
to
raise_error
(
Gitlab
::
Ci
::
Config
::
Node
::
Entry
::
InvalidError
)
end
end
end
context
'when value is not a hash'
do
...
...
spec/lib/gitlab/ci/config/node/null_spec.rb
浏览文件 @
87fe50f2
...
...
@@ -14,4 +14,10 @@ describe Gitlab::Ci::Config::Node::Null do
expect
(
entry
.
any_method
).
to
be
nil
end
end
describe
'#value'
do
it
'returns nill'
do
expect
(
entry
.
value
).
to
be
nil
end
end
end
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录