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
8c7374ca
Commit
8c7374ca
authored
Feb 23, 2018
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add operator / value types in pipeline expressions
parent
85176274
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
50 additions
and
15 deletions
+50
-15
lib/gitlab/ci/pipeline/expression/lexeme/equals.rb
lib/gitlab/ci/pipeline/expression/lexeme/equals.rb
+1
-2
lib/gitlab/ci/pipeline/expression/lexeme/null.rb
lib/gitlab/ci/pipeline/expression/lexeme/null.rb
+1
-2
lib/gitlab/ci/pipeline/expression/lexeme/operator.rb
lib/gitlab/ci/pipeline/expression/lexeme/operator.rb
+15
-0
lib/gitlab/ci/pipeline/expression/lexeme/string.rb
lib/gitlab/ci/pipeline/expression/lexeme/string.rb
+1
-2
lib/gitlab/ci/pipeline/expression/lexeme/value.rb
lib/gitlab/ci/pipeline/expression/lexeme/value.rb
+15
-0
lib/gitlab/ci/pipeline/expression/lexeme/variable.rb
lib/gitlab/ci/pipeline/expression/lexeme/variable.rb
+1
-2
lib/gitlab/ci/pipeline/expression/lexer.rb
lib/gitlab/ci/pipeline/expression/lexer.rb
+1
-1
lib/gitlab/ci/pipeline/expression/parser.rb
lib/gitlab/ci/pipeline/expression/parser.rb
+1
-1
spec/lib/gitlab/ci/pipeline/expression/statement_spec.rb
spec/lib/gitlab/ci/pipeline/expression/statement_spec.rb
+14
-5
No files found.
lib/gitlab/ci/pipeline/expression/lexeme/equals.rb
View file @
8c7374ca
...
...
@@ -3,9 +3,8 @@ module Gitlab
module
Pipeline
module
Expression
module
Lexeme
class
Equals
<
Lexeme
::
Base
class
Equals
<
Lexeme
::
Operator
PATTERN
=
/==/
.
freeze
TYPE
=
:operator
def
initialize
(
left
,
right
)
@left
=
left
...
...
lib/gitlab/ci/pipeline/expression/lexeme/null.rb
View file @
8c7374ca
...
...
@@ -3,9 +3,8 @@ module Gitlab
module
Pipeline
module
Expression
module
Lexeme
class
Null
<
Lexeme
::
Bas
e
class
Null
<
Lexeme
::
Valu
e
PATTERN
=
/null/
.
freeze
TYPE
=
:value
def
initialize
(
value
=
nil
)
@value
=
value
...
...
lib/gitlab/ci/pipeline/expression/lexeme/operator.rb
0 → 100644
View file @
8c7374ca
module
Gitlab
module
Ci
module
Pipeline
module
Expression
module
Lexeme
class
Operator
<
Lexeme
::
Base
def
self
.
type
:operator
end
end
end
end
end
end
end
lib/gitlab/ci/pipeline/expression/lexeme/string.rb
View file @
8c7374ca
...
...
@@ -3,9 +3,8 @@ module Gitlab
module
Pipeline
module
Expression
module
Lexeme
class
String
<
Lexeme
::
Bas
e
class
String
<
Lexeme
::
Valu
e
PATTERN
=
/"(?<string>.+?)"/
.
freeze
TYPE
=
:value
def
initialize
(
value
)
@value
=
value
...
...
lib/gitlab/ci/pipeline/expression/lexeme/value.rb
0 → 100644
View file @
8c7374ca
module
Gitlab
module
Ci
module
Pipeline
module
Expression
module
Lexeme
class
Value
<
Lexeme
::
Base
def
self
.
type
:value
end
end
end
end
end
end
end
lib/gitlab/ci/pipeline/expression/lexeme/variable.rb
View file @
8c7374ca
...
...
@@ -3,9 +3,8 @@ module Gitlab
module
Pipeline
module
Expression
module
Lexeme
class
Variable
<
Lexeme
::
Bas
e
class
Variable
<
Lexeme
::
Valu
e
PATTERN
=
/\$(?<name>\w+)/
.
freeze
TYPE
=
:value
def
initialize
(
name
)
@name
=
name
...
...
lib/gitlab/ci/pipeline/expression/lexer.rb
View file @
8c7374ca
...
...
@@ -10,7 +10,7 @@ module Gitlab
].
freeze
MAX_CYCLES
=
5
SyntaxError
=
Class
.
new
(
Sta
ndard
Error
)
SyntaxError
=
Class
.
new
(
Sta
tement
::
Statement
Error
)
def
initialize
(
statement
)
@scanner
=
StringScanner
.
new
(
statement
)
...
...
lib/gitlab/ci/pipeline/expression/parser.rb
View file @
8c7374ca
...
...
@@ -22,7 +22,7 @@ module Gitlab
end
end
rescue
StopIteration
@nodes
.
last
||
Expression
::
Lexeme
::
Null
.
new
@nodes
.
last
||
Lexeme
::
Null
.
new
end
def
self
.
seed
(
statement
)
...
...
spec/lib/gitlab/ci/pipeline/expression/statement_spec.rb
View file @
8c7374ca
...
...
@@ -23,11 +23,20 @@ describe Gitlab::Ci::Pipeline::Expression::Statement do
end
context
'when expression grammar is incorrect'
do
let
(
:text
)
{
'$VAR "text"'
}
it
'raises an error'
do
expect
{
subject
.
parse_tree
}
.
to
raise_error
described_class
::
StatementError
table
=
[
'$VAR "text"'
,
# missing operator
'== "123"'
,
# invalid right side
"'single quotes'"
,
# single quotes string
'$VAR =='
,
# invalid right side
'12345'
,
# unknown syntax
''
# empty statement
]
table
.
each
do
|
syntax
|
it
"raises an error when syntax is `
#{
syntax
}
`"
do
expect
{
described_class
.
new
(
syntax
,
pipeline
).
parse_tree
}
.
to
raise_error
described_class
::
StatementError
end
end
end
...
...
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