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
Jérome Perrin
gitlab-ce
Commits
24d56853
Commit
24d56853
authored
May 19, 2016
by
James Lopez
Browse files
Options
Browse Files
Download
Plain Diff
fix merge conflicts
parents
bac27df1
14669977
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
53 additions
and
12 deletions
+53
-12
app/models/member.rb
app/models/member.rb
+5
-4
lib/gitlab/import_export.rb
lib/gitlab/import_export.rb
+4
-0
lib/gitlab/import_export/import_service.rb
lib/gitlab/import_export/import_service.rb
+5
-1
lib/gitlab/import_export/members_mapper.rb
lib/gitlab/import_export/members_mapper.rb
+2
-2
lib/gitlab/import_export/relation_factory.rb
lib/gitlab/import_export/relation_factory.rb
+9
-1
lib/gitlab/import_export/uploads_restorer.rb
lib/gitlab/import_export/uploads_restorer.rb
+19
-0
lib/gitlab/import_export/uploads_saver.rb
lib/gitlab/import_export/uploads_saver.rb
+9
-4
No files found.
app/models/member.rb
View file @
24d56853
...
...
@@ -22,6 +22,7 @@ class Member < ActiveRecord::Base
include
Gitlab
::
Access
attr_accessor
:raw_invite_token
attr_accessor
:importing
belongs_to
:created_by
,
class_name:
"User"
belongs_to
:user
...
...
@@ -54,10 +55,10 @@ class Member < ActiveRecord::Base
scope
:owners
,
->
{
where
(
access_level:
OWNER
)
}
before_validation
:generate_invite_token
,
on: :create
,
if:
->
(
member
)
{
member
.
invite_email
.
present?
}
after_create
:send_invite
,
if: :invite?
after_create
:create_notification_setting
,
unless:
:invite?
after_create
:post_create_hook
,
unless:
:invite?
after_update
:post_update_hook
,
unless:
:invite?
after_create
:send_invite
,
if: :invite?
,
unless: :importing
after_create
:create_notification_setting
,
unless:
[
:invite?
,
:importing
]
after_create
:post_create_hook
,
unless:
[
:invite?
,
:importing
]
after_update
:post_update_hook
,
unless:
[
:invite?
,
:importing
]
after_destroy
:post_destroy_hook
,
unless: :invite?
delegate
:name
,
:username
,
:email
,
to: :user
,
prefix:
true
...
...
lib/gitlab/import_export.rb
View file @
24d56853
...
...
@@ -27,5 +27,9 @@ module Gitlab
def
version
VERSION
end
def
reset_tokens?
true
end
end
end
lib/gitlab/import_export/import_service.rb
View file @
24d56853
...
...
@@ -16,7 +16,7 @@ module Gitlab
def
execute
Gitlab
::
ImportExport
::
Importer
.
import
(
archive_file:
@archive_file
,
shared:
@shared
)
if
[
restore_version
,
restore_project_tree
,
restore_repo
,
restore_wiki_repo
].
all?
if
[
restore_version
,
restore_project_tree
,
restore_repo
,
restore_wiki_repo
,
restore_uploads
].
all?
project_tree
.
project
else
project_tree
.
project
.
destroy
if
project_tree
.
project
...
...
@@ -52,6 +52,10 @@ module Gitlab
project:
ProjectWiki
.
new
(
project_tree
.
project
)).
restore
end
def
restore_uploads
Gitlab
::
ImportExport
::
UploadsRestorer
.
restore
(
project:
project_tree
.
project
,
shared:
@shared
)
end
def
path_with_namespace
(
project_path
)
File
.
join
(
@namespace
.
path
,
project_path
)
end
...
...
lib/gitlab/import_export/members_mapper.rb
View file @
24d56853
...
...
@@ -50,11 +50,11 @@ module Gitlab
end
def
member_hash
(
member
)
member
.
except
(
'id'
).
merge
(
source_id:
@project
.
id
)
member
.
except
(
'id'
).
merge
(
source_id:
@project
.
id
,
importing:
true
)
end
def
default_project_member_hash
{
user:
@user
,
access_level:
ProjectMember
::
MASTER
,
source_id:
@project
.
id
}
{
user:
@user
,
access_level:
ProjectMember
::
MASTER
,
source_id:
@project
.
id
,
importing:
true
}
end
def
find_project_user_query
(
member
)
...
...
lib/gitlab/import_export/relation_factory.rb
View file @
24d56853
...
...
@@ -12,7 +12,7 @@ module Gitlab
builds:
'Ci::Build'
,
hooks:
'ProjectHook'
}.
freeze
USER_REFERENCES
=
%w(author_id assignee_id updated_by_id)
.
freeze
USER_REFERENCES
=
%w(author_id assignee_id updated_by_id
user_id
)
.
freeze
def
create
(
relation_sym
:,
relation_hash
:,
members_mapper
:,
user_admin
:)
relation_sym
=
parse_relation_sym
(
relation_sym
)
...
...
@@ -21,6 +21,7 @@ module Gitlab
update_missing_author
(
relation_hash
,
members_mapper
,
user_admin
)
if
relation_sym
==
:notes
update_user_references
(
relation_hash
,
members_mapper
.
map
)
update_project_references
(
relation_hash
,
klass
)
reset_tokens
(
relation_hash
)
if
relation_sym
==
'Ci::Trigger'
generate_imported_object
(
klass
,
relation_hash
,
relation_sym
)
end
...
...
@@ -88,6 +89,13 @@ module Gitlab
relation_hash
[
'gl_project_id'
]
=
project_id
if
relation_hash
[
'gl_project_id'
]
end
def
reset_tokens
(
relation_hash
)
return
unless
Gitlab
::
ImportExport
.
reset_tokens?
# If we import/export a project to the same instance, tokens will have to be reseated.
relation_hash
[
'token'
]
=
nil
end
def
relation_class
(
relation_sym
)
relation_sym
.
to_s
.
classify
.
constantize
end
...
...
lib/gitlab/import_export/uploads_restorer.rb
0 → 100644
View file @
24d56853
module
Gitlab
module
ImportExport
class
UploadsRestorer
<
UploadsSaver
class
<<
self
alias_method
:restore
,
:save
end
def
save
return
true
unless
File
.
directory?
(
uploads_export_path
)
copy_files
(
uploads_export_path
,
uploads_path
)
rescue
=>
e
@shared
.
error
(
e
)
false
end
end
end
end
lib/gitlab/import_export/uploads_saver.rb
View file @
24d56853
...
...
@@ -14,21 +14,26 @@ module Gitlab
def
save
return
true
unless
File
.
directory?
(
uploads_path
)
FileUtils
.
copy_entry
(
uploads_path
,
uploads_export_path
)
true
copy_files
(
uploads_path
,
uploads_export_path
)
rescue
=>
e
@shared
.
error
(
e
.
message
)
@shared
.
error
(
e
)
false
end
private
def
copy_files
(
source
,
destination
)
FileUtils
.
mkdir_p
(
destination
)
FileUtils
.
copy_entry
(
source
,
destination
)
true
end
def
uploads_export_path
File
.
join
(
@shared
.
export_path
,
'uploads'
)
end
def
uploads_path
File
.
join
(
Rails
.
root
.
join
(
'public/uploads'
),
project
.
path_with_namespace
)
File
.
join
(
Rails
.
root
.
join
(
'public/uploads'
),
@
project
.
path_with_namespace
)
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