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
ec512406
Commit
ec512406
authored
Jul 12, 2019
by
George Koltsov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add commit_id to AttributeCleaner::ALLOWED_REFERENCES
parent
ebed862a
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
16 additions
and
10 deletions
+16
-10
app/models/merge_request.rb
app/models/merge_request.rb
+5
-3
changelogs/unreleased/georgekoltsov-63955-fix-import-with-source-branch-deleted.yml
...gekoltsov-63955-fix-import-with-source-branch-deleted.yml
+1
-1
lib/gitlab/import_export/attribute_cleaner.rb
lib/gitlab/import_export/attribute_cleaner.rb
+1
-1
spec/lib/gitlab/import_export/attribute_cleaner_spec.rb
spec/lib/gitlab/import_export/attribute_cleaner_spec.rb
+7
-3
spec/models/merge_request_spec.rb
spec/models/merge_request_spec.rb
+2
-2
No files found.
app/models/merge_request.rb
View file @
ec512406
...
...
@@ -588,9 +588,11 @@ class MergeRequest < ApplicationRecord
end
def
diff_refs
return
merge_request_diff
.
diff_refs
if
importing?
persisted?
?
merge_request_diff
.
diff_refs
:
repository_diff_refs
if
importing?
||
persisted?
merge_request_diff
.
diff_refs
else
repository_diff_refs
end
end
# Instead trying to fetch the
...
...
changelogs/unreleased/georgekoltsov-63955-fix-import-with-source-branch-deleted.yml
View file @
ec512406
---
title
:
Always return MR diff_refs if importing
title
:
Fix a bug that prevented projects containing merge request diff comments from being imported
merge_request
:
30630
author
:
type
:
fixed
lib/gitlab/import_export/attribute_cleaner.rb
View file @
ec512406
...
...
@@ -3,7 +3,7 @@
module
Gitlab
module
ImportExport
class
AttributeCleaner
ALLOWED_REFERENCES
=
RelationFactory
::
PROJECT_REFERENCES
+
RelationFactory
::
USER_REFERENCES
+
[
'group_id'
]
ALLOWED_REFERENCES
=
RelationFactory
::
PROJECT_REFERENCES
+
RelationFactory
::
USER_REFERENCES
+
%w[group_id commit_id
]
PROHIBITED_REFERENCES
=
Regexp
.
union
(
/\Acached_markdown_version\Z/
,
/_id\Z/
,
/_html\Z/
).
freeze
def
self
.
clean
(
*
args
)
...
...
spec/lib/gitlab/import_export/attribute_cleaner_spec.rb
View file @
ec512406
...
...
@@ -22,7 +22,9 @@ describe Gitlab::ImportExport::AttributeCleaner do
'some_html'
=>
'<p>dodgy html</p>'
,
'legit_html'
=>
'<p>legit html</p>'
,
'_html'
=>
'<p>perfectly ordinary html</p>'
,
'cached_markdown_version'
=>
12345
'cached_markdown_version'
=>
12345
,
'group_id'
=>
99
,
'commit_id'
=>
99
}
end
...
...
@@ -31,7 +33,9 @@ describe Gitlab::ImportExport::AttributeCleaner do
'project_id'
=>
99
,
'user_id'
=>
99
,
'random_id_in_the_middle'
=>
99
,
'notid'
=>
99
'notid'
=>
99
,
'group_id'
=>
99
,
'commit_id'
=>
99
}
end
...
...
@@ -59,6 +63,6 @@ describe Gitlab::ImportExport::AttributeCleaner do
it
'does not remove excluded key if not listed'
do
parsed_hash
=
described_class
.
clean
(
relation_hash:
unsafe_hash
,
relation_class:
relation_class
)
expect
(
parsed_hash
.
keys
).
to
eq
post_safe_hash
.
keys
+
excluded_keys
expect
(
parsed_hash
.
keys
).
to
match_array
post_safe_hash
.
keys
+
excluded_keys
end
end
spec/models/merge_request_spec.rb
View file @
ec512406
...
...
@@ -2454,13 +2454,13 @@ describe MergeRequest do
describe
"#diff_refs"
do
context
"with diffs"
do
subject
{
create
(
:merge_request
,
:with_diffs
)
}
let
(
:expected_diff_refs
)
{
let
(
:expected_diff_refs
)
do
Gitlab
::
Diff
::
DiffRefs
.
new
(
base_sha:
subject
.
merge_request_diff
.
base_commit_sha
,
start_sha:
subject
.
merge_request_diff
.
start_commit_sha
,
head_sha:
subject
.
merge_request_diff
.
head_commit_sha
)
}
end
it
"does not touch the repository"
do
subject
# Instantiate the object
...
...
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