Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
886988c9
Commit
886988c9
authored
Feb 27, 2018
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Do not use keyword args to pass expression variables
parent
3938d1c3
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
13 additions
and
6 deletions
+13
-6
lib/gitlab/ci/pipeline/expression/lexeme/equals.rb
lib/gitlab/ci/pipeline/expression/lexeme/equals.rb
+1
-1
lib/gitlab/ci/pipeline/expression/lexeme/null.rb
lib/gitlab/ci/pipeline/expression/lexeme/null.rb
+1
-1
lib/gitlab/ci/pipeline/expression/lexeme/string.rb
lib/gitlab/ci/pipeline/expression/lexeme/string.rb
+1
-1
lib/gitlab/ci/pipeline/expression/lexeme/variable.rb
lib/gitlab/ci/pipeline/expression/lexeme/variable.rb
+2
-2
lib/gitlab/ci/pipeline/expression/statement.rb
lib/gitlab/ci/pipeline/expression/statement.rb
+1
-1
spec/lib/gitlab/ci/pipeline/expression/lexeme/variable_spec.rb
...lib/gitlab/ci/pipeline/expression/lexeme/variable_spec.rb
+7
-0
No files found.
lib/gitlab/ci/pipeline/expression/lexeme/equals.rb
View file @
886988c9
...
@@ -11,7 +11,7 @@ module Gitlab
...
@@ -11,7 +11,7 @@ module Gitlab
@right
=
right
@right
=
right
end
end
def
evaluate
(
**
variables
)
def
evaluate
(
variables
=
{}
)
@left
.
evaluate
(
variables
)
==
@right
.
evaluate
(
variables
)
@left
.
evaluate
(
variables
)
==
@right
.
evaluate
(
variables
)
end
end
...
...
lib/gitlab/ci/pipeline/expression/lexeme/null.rb
View file @
886988c9
...
@@ -10,7 +10,7 @@ module Gitlab
...
@@ -10,7 +10,7 @@ module Gitlab
@value
=
nil
@value
=
nil
end
end
def
evaluate
(
**
_
)
def
evaluate
(
variables
=
{}
)
nil
nil
end
end
...
...
lib/gitlab/ci/pipeline/expression/lexeme/string.rb
View file @
886988c9
...
@@ -10,7 +10,7 @@ module Gitlab
...
@@ -10,7 +10,7 @@ module Gitlab
@value
=
value
@value
=
value
end
end
def
evaluate
(
**
_
)
def
evaluate
(
variables
=
{}
)
@value
.
to_s
@value
.
to_s
end
end
...
...
lib/gitlab/ci/pipeline/expression/lexeme/variable.rb
View file @
886988c9
...
@@ -10,8 +10,8 @@ module Gitlab
...
@@ -10,8 +10,8 @@ module Gitlab
@name
=
name
@name
=
name
end
end
def
evaluate
(
**
variables
)
def
evaluate
(
variables
=
{}
)
variables
[
@name
.
to_sym
]
HashWithIndifferentAccess
.
new
(
variables
).
fetch
(
@name
,
nil
)
end
end
def
self
.
build
(
string
)
def
self
.
build
(
string
)
...
...
lib/gitlab/ci/pipeline/expression/statement.rb
View file @
886988c9
...
@@ -18,7 +18,7 @@ module Gitlab
...
@@ -18,7 +18,7 @@ module Gitlab
@lexer
=
Expression
::
Lexer
.
new
(
statement
)
@lexer
=
Expression
::
Lexer
.
new
(
statement
)
@variables
=
pipeline
.
variables
.
map
do
|
variable
|
@variables
=
pipeline
.
variables
.
map
do
|
variable
|
[
variable
.
key
.
to_sym
,
variable
.
value
]
[
variable
.
key
,
variable
.
value
]
end
end
end
end
...
...
spec/lib/gitlab/ci/pipeline/expression/lexeme/variable_spec.rb
View file @
886988c9
...
@@ -22,6 +22,13 @@ describe Gitlab::Ci::Pipeline::Expression::Lexeme::Variable do
...
@@ -22,6 +22,13 @@ describe Gitlab::Ci::Pipeline::Expression::Lexeme::Variable do
.
to
eq
'my variable'
.
to
eq
'my variable'
end
end
it
'allows to use a string as a variable key too'
do
variable
=
described_class
.
new
(
'VARIABLE'
)
expect
(
variable
.
evaluate
(
'VARIABLE'
=>
'my variable'
))
.
to
eq
'my variable'
end
it
'returns nil if it is not defined'
do
it
'returns nil if it is not defined'
do
variable
=
described_class
.
new
(
'VARIABLE'
)
variable
=
described_class
.
new
(
'VARIABLE'
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment