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
b240012c
Commit
b240012c
authored
Apr 29, 2019
by
charlieablett
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Further clarify `attribute_cleaner`
parent
4bd331a5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
10 deletions
+4
-10
lib/gitlab/import_export/attribute_cleaner.rb
lib/gitlab/import_export/attribute_cleaner.rb
+4
-10
No files found.
lib/gitlab/import_export/attribute_cleaner.rb
View file @
b240012c
...
...
@@ -4,6 +4,7 @@ module Gitlab
module
ImportExport
class
AttributeCleaner
ALLOWED_REFERENCES
=
RelationFactory
::
PROJECT_REFERENCES
+
RelationFactory
::
USER_REFERENCES
+
[
'group_id'
]
PROHIBITED_SUFFIXES
=
%w(_id _html)
.
freeze
def
self
.
clean
(
*
args
)
new
(
*
args
).
clean
...
...
@@ -17,24 +18,17 @@ module Gitlab
def
clean
@relation_hash
.
reject
do
|
key
,
_value
|
prohibited_key?
(
key
)
||
!
@relation_class
.
attribute_method?
(
key
)
||
excluded_key?
(
key
)
(
prohibited_key?
(
key
)
&&
!
permitted_key?
(
key
)
)
||
!
@relation_class
.
attribute_method?
(
key
)
||
excluded_key?
(
key
)
end
.
except
(
'id'
)
end
private
def
prohibited_key?
(
key
)
return
false
if
allowed_reference?
(
key
)
return
true
if
'cached_markdown_version'
.
equal?
(
key
)
prohibited_suffixes
=
%w(_id _html)
prohibited_suffixes
.
any?
do
|
suffix
|
true
if
key
.
end_with?
(
suffix
)
end
'cached_markdown_version'
==
key
||
PROHIBITED_SUFFIXES
.
any?
{
|
suffix
|
key
.
end_with?
(
suffix
)}
end
def
allowed_reference
?
(
key
)
def
permitted_key
?
(
key
)
ALLOWED_REFERENCES
.
include?
(
key
)
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