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
0
Merge Requests
0
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
Boxiang Sun
gitlab-ce
Commits
ef26622d
Commit
ef26622d
authored
Aug 16, 2018
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Do not modify extensible CI/CD entries by reference
parent
58414c14
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
18 deletions
+13
-18
lib/gitlab/ci/config/extendable/collection.rb
lib/gitlab/ci/config/extendable/collection.rb
+3
-4
lib/gitlab/ci/config/extendable/entry.rb
lib/gitlab/ci/config/extendable/entry.rb
+10
-14
No files found.
lib/gitlab/ci/config/extendable/collection.rb
View file @
ef26622d
...
@@ -7,16 +7,15 @@ module Gitlab
...
@@ -7,16 +7,15 @@ module Gitlab
ExtensionError
=
Class
.
new
(
StandardError
)
ExtensionError
=
Class
.
new
(
StandardError
)
def
initialize
(
hash
,
context
=
hash
)
def
initialize
(
hash
)
@hash
=
hash
@hash
=
hash
@context
=
context
end
end
def
each
def
each
@hash
.
each_pair
do
|
key
,
value
|
@hash
.
each_pair
do
|
key
,
value
|
next
unless
value
.
key?
(
:extends
)
next
unless
value
.
key?
(
:extends
)
yield
Extendable
::
Entry
.
new
(
key
,
value
,
@context
)
yield
Extendable
::
Entry
.
new
(
key
,
@hash
)
end
end
end
end
...
@@ -24,7 +23,7 @@ module Gitlab
...
@@ -24,7 +23,7 @@ module Gitlab
each
do
|
entry
|
each
do
|
entry
|
raise
ExtensionError
unless
entry
.
valid?
raise
ExtensionError
unless
entry
.
valid?
@hash
[
entry
.
key
]
=
entry
.
extend!
entry
.
extend!
end
end
end
end
end
end
...
...
lib/gitlab/ci/config/extendable/entry.rb
View file @
ef26622d
...
@@ -5,10 +5,9 @@ module Gitlab
...
@@ -5,10 +5,9 @@ module Gitlab
class
Entry
class
Entry
attr_reader
:key
attr_reader
:key
def
initialize
(
key
,
value
,
context
,
parent
=
nil
)
def
initialize
(
key
,
hash
,
parent
=
nil
)
@key
=
key
@key
=
key
@value
=
value
@hash
=
hash
@context
=
context
@parent
=
parent
@parent
=
parent
end
end
...
@@ -16,32 +15,29 @@ module Gitlab
...
@@ -16,32 +15,29 @@ module Gitlab
true
true
end
end
# def circular_dependency?
def
value
# @extends.to_s == @key.to_s
@value
||=
@hash
.
fetch
(
@key
)
#
end
end
def
base
def
base
Extendable
::
Entry
Extendable
::
Entry
.
new
(
extends
,
@
context
.
fetch
(
extends
),
@context
,
self
)
.
new
(
extends
,
@
hash
,
self
)
.
extend!
.
extend!
end
end
def
extensible?
def
extensible?
@
value
.
key?
(
:extends
)
value
.
key?
(
:extends
)
end
end
def
extends
def
extends
@
value
.
fetch
(
:extends
).
to_sym
value
.
fetch
(
:extends
).
to_sym
end
end
def
extend!
def
extend!
if
extensible?
if
extensible?
original
=
@value
.
dup
@hash
[
key
]
=
base
.
deep_merge
(
value
)
parent
=
base
.
dup
@value
.
clear
.
deep_merge!
(
parent
).
deep_merge!
(
original
)
else
else
@value
.
to_h
value
end
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