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
10a486b3
Commit
10a486b3
authored
Sep 14, 2017
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove YAML processor refactoring stubs and fix specs
parent
241197c2
Changes
3
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
81 additions
and
85 deletions
+81
-85
lib/gitlab/ci/build/policy/refs.rb
lib/gitlab/ci/build/policy/refs.rb
+1
-1
lib/gitlab/ci/yaml_processor.rb
lib/gitlab/ci/yaml_processor.rb
+25
-31
spec/lib/gitlab/ci/yaml_processor_spec.rb
spec/lib/gitlab/ci/yaml_processor_spec.rb
+55
-53
No files found.
lib/gitlab/ci/build/policy/refs.rb
View file @
10a486b3
...
@@ -26,7 +26,7 @@ module Gitlab
...
@@ -26,7 +26,7 @@ module Gitlab
def
matches_pattern?
(
pattern
,
pipeline
)
def
matches_pattern?
(
pattern
,
pipeline
)
return
true
if
pipeline
.
tag?
&&
pattern
==
'tags'
return
true
if
pipeline
.
tag?
&&
pattern
==
'tags'
return
true
if
!
pipeline
.
tag
?
&&
pattern
==
'branches'
return
true
if
pipeline
.
branch
?
&&
pattern
==
'branches'
return
true
if
source_to_pattern
(
pipeline
.
source
)
==
pattern
return
true
if
source_to_pattern
(
pipeline
.
source
)
==
pattern
if
pattern
.
first
==
"/"
&&
pattern
.
last
==
"/"
if
pattern
.
first
==
"/"
&&
pattern
.
last
==
"/"
...
...
lib/gitlab/ci/yaml_processor.rb
View file @
10a486b3
...
@@ -22,28 +22,12 @@ module Gitlab
...
@@ -22,28 +22,12 @@ module Gitlab
end
end
# REFACTORING STUB, remove this method, used only in tests.
#
def
builds_for_stage_and_ref
(
stage
,
ref
,
tag
=
false
,
source
=
nil
)
pipeline_stage_builds
(
stage
,
::
Ci
::
Pipeline
.
new
(
ref:
ref
,
source:
source
,
tag:
tag
))
end
def
builds
def
builds
@jobs
.
map
do
|
name
,
_
|
@jobs
.
map
do
|
name
,
_
|
build_attributes
(
name
)
build_attributes
(
name
)
end
end
end
end
def
stage_seeds
(
pipeline
)
seeds
=
@stages
.
uniq
.
map
do
|
stage
|
builds
=
pipeline_stage_builds
(
stage
,
pipeline
)
Gitlab
::
Ci
::
Stage
::
Seed
.
new
(
pipeline
,
stage
,
builds
)
if
builds
.
any?
end
seeds
.
compact
end
def
build_attributes
(
name
)
def
build_attributes
(
name
)
job
=
@jobs
[
name
.
to_sym
]
||
{}
job
=
@jobs
[
name
.
to_sym
]
||
{}
...
@@ -71,21 +55,8 @@ module Gitlab
...
@@ -71,21 +55,8 @@ module Gitlab
}.
compact
}
}.
compact
}
end
end
def
self
.
validation_message
(
content
)
return
'Please provide content of .gitlab-ci.yml'
if
content
.
blank?
begin
Gitlab
::
Ci
::
YamlProcessor
.
new
(
content
)
nil
rescue
ValidationError
,
Psych
::
SyntaxError
=>
e
e
.
message
end
end
private
def
pipeline_stage_builds
(
stage
,
pipeline
)
def
pipeline_stage_builds
(
stage
,
pipeline
)
s
tage
_jobs
=
@jobs
.
select
do
|
_
,
job
|
s
elected
_jobs
=
@jobs
.
select
do
|
_
,
job
|
next
unless
job
[
:stage
]
==
stage
next
unless
job
[
:stage
]
==
stage
only_specs
=
Gitlab
::
Ci
::
Build
::
Policy
only_specs
=
Gitlab
::
Ci
::
Build
::
Policy
...
@@ -97,8 +68,31 @@ module Gitlab
...
@@ -97,8 +68,31 @@ module Gitlab
except_specs
.
none?
{
|
spec
|
spec
.
satisfied_by?
(
pipeline
,
path:
@path
)
}
except_specs
.
none?
{
|
spec
|
spec
.
satisfied_by?
(
pipeline
,
path:
@path
)
}
end
end
stage_jobs
.
map
{
|
_
,
job
|
build_attributes
(
job
[
:name
])
}
selected_jobs
.
map
{
|
_
,
job
|
build_attributes
(
job
[
:name
])
}
end
def
stage_seeds
(
pipeline
)
seeds
=
@stages
.
uniq
.
map
do
|
stage
|
builds
=
pipeline_stage_builds
(
stage
,
pipeline
)
Gitlab
::
Ci
::
Stage
::
Seed
.
new
(
pipeline
,
stage
,
builds
)
if
builds
.
any?
end
seeds
.
compact
end
def
self
.
validation_message
(
content
)
return
'Please provide content of .gitlab-ci.yml'
if
content
.
blank?
begin
Gitlab
::
Ci
::
YamlProcessor
.
new
(
content
)
nil
rescue
ValidationError
,
Psych
::
SyntaxError
=>
e
e
.
message
end
end
end
private
def
initial_parsing
def
initial_parsing
##
##
...
...
spec/lib/gitlab/ci/yaml_processor_spec.rb
View file @
10a486b3
This diff is collapsed.
Click to expand it.
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