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
...
@@ -3,9 +3,8 @@ module Gitlab
module
Pipeline
module
Pipeline
module
Expression
module
Expression
module
Lexeme
module
Lexeme
class
Equals
<
Lexeme
::
Base
class
Equals
<
Lexeme
::
Operator
PATTERN
=
/==/
.
freeze
PATTERN
=
/==/
.
freeze
TYPE
=
:operator
def
initialize
(
left
,
right
)
def
initialize
(
left
,
right
)
@left
=
left
@left
=
left
...
...
lib/gitlab/ci/pipeline/expression/lexeme/null.rb
View file @
8c7374ca
...
@@ -3,9 +3,8 @@ module Gitlab
...
@@ -3,9 +3,8 @@ module Gitlab
module
Pipeline
module
Pipeline
module
Expression
module
Expression
module
Lexeme
module
Lexeme
class
Null
<
Lexeme
::
Bas
e
class
Null
<
Lexeme
::
Valu
e
PATTERN
=
/null/
.
freeze
PATTERN
=
/null/
.
freeze
TYPE
=
:value
def
initialize
(
value
=
nil
)
def
initialize
(
value
=
nil
)
@value
=
value
@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
...
@@ -3,9 +3,8 @@ module Gitlab
module
Pipeline
module
Pipeline
module
Expression
module
Expression
module
Lexeme
module
Lexeme
class
String
<
Lexeme
::
Bas
e
class
String
<
Lexeme
::
Valu
e
PATTERN
=
/"(?<string>.+?)"/
.
freeze
PATTERN
=
/"(?<string>.+?)"/
.
freeze
TYPE
=
:value
def
initialize
(
value
)
def
initialize
(
value
)
@value
=
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
...
@@ -3,9 +3,8 @@ module Gitlab
module
Pipeline
module
Pipeline
module
Expression
module
Expression
module
Lexeme
module
Lexeme
class
Variable
<
Lexeme
::
Bas
e
class
Variable
<
Lexeme
::
Valu
e
PATTERN
=
/\$(?<name>\w+)/
.
freeze
PATTERN
=
/\$(?<name>\w+)/
.
freeze
TYPE
=
:value
def
initialize
(
name
)
def
initialize
(
name
)
@name
=
name
@name
=
name
...
...
lib/gitlab/ci/pipeline/expression/lexer.rb
View file @
8c7374ca
...
@@ -10,7 +10,7 @@ module Gitlab
...
@@ -10,7 +10,7 @@ module Gitlab
].
freeze
].
freeze
MAX_CYCLES
=
5
MAX_CYCLES
=
5
SyntaxError
=
Class
.
new
(
Sta
ndard
Error
)
SyntaxError
=
Class
.
new
(
Sta
tement
::
Statement
Error
)
def
initialize
(
statement
)
def
initialize
(
statement
)
@scanner
=
StringScanner
.
new
(
statement
)
@scanner
=
StringScanner
.
new
(
statement
)
...
...
lib/gitlab/ci/pipeline/expression/parser.rb
View file @
8c7374ca
...
@@ -22,7 +22,7 @@ module Gitlab
...
@@ -22,7 +22,7 @@ module Gitlab
end
end
end
end
rescue
StopIteration
rescue
StopIteration
@nodes
.
last
||
Expression
::
Lexeme
::
Null
.
new
@nodes
.
last
||
Lexeme
::
Null
.
new
end
end
def
self
.
seed
(
statement
)
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
...
@@ -23,11 +23,20 @@ describe Gitlab::Ci::Pipeline::Expression::Statement do
end
end
context
'when expression grammar is incorrect'
do
context
'when expression grammar is incorrect'
do
let
(
:text
)
{
'$VAR "text"'
}
table
=
[
'$VAR "text"'
,
# missing operator
it
'raises an error'
do
'== "123"'
,
# invalid right side
expect
{
subject
.
parse_tree
}
"'single quotes'"
,
# single quotes string
.
to
raise_error
described_class
::
StatementError
'$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
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