BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
3a131383
Commit
3a131383
authored
Mar 14, 2016
by
James Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed MR issue and refactored some stuff
parent
76efdea7
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
13 deletions
+10
-13
merge_request.rb
app/models/merge_request.rb
+1
-1
members_mapper.rb
app/services/projects/import_export/members_mapper.rb
+2
-6
relation_factory.rb
app/services/projects/import_export/relation_factory.rb
+7
-6
No files found.
app/models/merge_request.rb
View file @
3a131383
...
...
@@ -125,7 +125,7 @@ class MergeRequest < ActiveRecord::Base
end
end
validates
:source_project
,
presence:
true
,
unless:
:allow_broken
validates
:source_project
,
presence:
true
,
unless:
[
:allow_broken
,
:importing
]
validates
:source_branch
,
presence:
true
validates
:target_project
,
presence:
true
validates
:target_branch
,
presence:
true
...
...
app/services/projects/import_export/members_mapper.rb
View file @
3a131383
...
...
@@ -13,12 +13,6 @@ module Projects
end
def
map
@project_member_map
||=
project_member_map
end
private
def
project_member_map
@project_member_map
=
Hash
.
new
(
default_project_member
)
@exported_members
.
each
do
|
member
|
existing_user
=
User
.
where
(
find_project_user_query
(
member
)).
first
...
...
@@ -27,6 +21,8 @@ module Projects
@project_member_map
end
private
def
assign_member
(
existing_user
,
member
)
old_user_id
=
member
[
'user'
][
'id'
]
member
[
'user'
]
=
existing_user
...
...
app/services/projects/import_export/relation_factory.rb
View file @
3a131383
...
...
@@ -10,18 +10,19 @@ module Projects
relation_sym
=
parse_relation_sym
(
relation_sym
)
klass
=
relation_class
(
relation_sym
)
relation_hash
.
delete
(
'id'
)
#screw IDs for now
#TODO refactor this...
if
relation_sym
==
:merge_requests
relation_hash
[
'target_project_id'
]
=
relation_hash
.
delete
(
'project_id'
)
relation_hash
[
'source_project_id'
]
=
-
1
relation_hash
[
'importing'
]
=
true
end
handle_merge_requests
(
relation_hash
)
if
relation_sym
==
:merge_requests
update_user_references
(
relation_hash
,
members_map
)
klass
.
new
(
relation_hash
)
end
private
def
handle_merge_requests
(
relation_hash
)
relation_hash
[
'target_project_id'
]
=
relation_hash
.
delete
(
'project_id'
)
relation_hash
[
'source_project_id'
]
=
-
1
relation_hash
[
'importing'
]
=
true
end
#TODO nice to have, optimize this to only get called for specific models
def
update_user_references
(
relation_hash
,
members_map
)
USER_REFERENCES
.
each
do
|
reference
|
...
...
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