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
c306eda8
Commit
c306eda8
authored
Jan 06, 2021
by
Pedro Pombeiro
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Address MR review comments
parent
1d2c83cf
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
18 deletions
+18
-18
lib/gitlab/ci/variables/collection/sorted.rb
lib/gitlab/ci/variables/collection/sorted.rb
+4
-8
spec/lib/gitlab/ci/variables/collection/sorted_spec.rb
spec/lib/gitlab/ci/variables/collection/sorted_spec.rb
+14
-10
No files found.
lib/gitlab/ci/variables/collection/sorted.rb
View file @
c306eda8
...
...
@@ -13,9 +13,7 @@ module Gitlab
end
def
valid?
strong_memoize
(
:valid
)
do
errors
.
nil?
end
errors
.
nil?
end
# errors sorts an array of variables, ignoring unknown variable references,
...
...
@@ -26,7 +24,7 @@ module Gitlab
strong_memoize
(
:errors
)
do
# Check for cyclic dependencies and build error message in that case
errors
=
each_strongly_connected_component
.
filter_map
do
|
component
|
"
#{
component
.
map
{
|
v
|
v
[
:key
]
}
.inspect}"
if
component
.
size
>
1
component
.
map
{
|
v
|
v
[
:key
]
}.
inspect
if
component
.
size
>
1
end
"circular variable reference detected:
#{
errors
.
join
(
', '
)
}
"
if
errors
.
any?
...
...
@@ -38,16 +36,14 @@ module Gitlab
def
sort
return
@variables
if
Feature
.
disabled?
(
:variable_inside_variable
)
clear_memoization
(
:
valid
)
clear_memoization
(
:
errors
)
begin
# Perform a topological sort
variables
=
tsort
valid
=
true
strong_memoize
(
:errors
)
{
nil
}
rescue
TSort
::
Cyclic
variables
=
@variables
valid
=
false
end
strong_memoize
(
:valid
)
{
valid
}
variables
end
...
...
spec/lib/gitlab/ci/variables/collection/sorted_spec.rb
View file @
c306eda8
...
...
@@ -3,15 +3,11 @@
require
'spec_helper'
RSpec
.
describe
Gitlab
::
Ci
::
Variables
::
Collection
::
Sorted
do
let
(
:variable_inside_variable_enabled
)
{
false
}
before
do
stub_feature_flags
(
variable_inside_variable:
variable_inside_variable_enabled
)
end
describe
'#errors'
do
context
'when FF :variable_inside_variable is disabled'
do
let
(
:variable_inside_variable_enabled
)
{
false
}
before
do
stub_feature_flags
(
variable_inside_variable:
false
)
end
context
'table tests'
do
using
RSpec
::
Parameterized
::
TableSyntax
...
...
@@ -71,7 +67,9 @@ RSpec.describe Gitlab::Ci::Variables::Collection::Sorted do
end
context
'when FF :variable_inside_variable is enabled'
do
let
(
:variable_inside_variable_enabled
)
{
true
}
before
do
stub_feature_flags
(
variable_inside_variable:
true
)
end
context
'table tests'
do
using
RSpec
::
Parameterized
::
TableSyntax
...
...
@@ -118,7 +116,9 @@ RSpec.describe Gitlab::Ci::Variables::Collection::Sorted do
describe
'#sort'
do
context
'when FF :variable_inside_variable is disabled'
do
let
(
:variable_inside_variable_enabled
)
{
false
}
before
do
stub_feature_flags
(
variable_inside_variable:
false
)
end
context
'table tests'
do
using
RSpec
::
Parameterized
::
TableSyntax
...
...
@@ -174,7 +174,11 @@ RSpec.describe Gitlab::Ci::Variables::Collection::Sorted do
end
context
'when FF :variable_inside_variable is enabled'
do
let
(
:variable_inside_variable_enabled
)
{
true
}
before
do
stub_licensed_features
(
group_saml_group_sync:
true
)
stub_feature_flags
(
saml_group_links:
true
)
stub_feature_flags
(
variable_inside_variable:
true
)
end
context
'table tests'
do
using
RSpec
::
Parameterized
::
TableSyntax
...
...
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