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
Tatuya Kamada
gitlab-ce
Commits
9ecebaae
Commit
9ecebaae
authored
Jun 14, 2016
by
James Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adding notifications stuff and more refactoring for exporting projects
parent
fe370b1c
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
84 additions
and
29 deletions
+84
-29
app/controllers/import/gitlab_projects_controller.rb
app/controllers/import/gitlab_projects_controller.rb
+1
-1
app/controllers/projects_controller.rb
app/controllers/projects_controller.rb
+1
-1
app/mailers/emails/projects.rb
app/mailers/emails/projects.rb
+13
-0
app/services/notification_service.rb
app/services/notification_service.rb
+8
-0
app/services/projects/create_service.rb
app/services/projects/create_service.rb
+0
-2
app/services/projects/import_export/export_service.rb
app/services/projects/import_export/export_service.rb
+13
-2
app/views/notify/project_was_exported_email.html.haml
app/views/notify/project_was_exported_email.html.haml
+8
-0
app/views/notify/project_was_exported_email.text.erb
app/views/notify/project_was_exported_email.text.erb
+6
-0
app/views/notify/project_was_not_exported_email.html.haml
app/views/notify/project_was_not_exported_email.html.haml
+7
-0
app/views/notify/project_was_not_exported_email.text.erb
app/views/notify/project_was_not_exported_email.text.erb
+5
-0
app/workers/project_export_worker.rb
app/workers/project_export_worker.rb
+1
-0
lib/gitlab/gitlab_import/project_creator.rb
lib/gitlab/gitlab_import/project_creator.rb
+12
-9
lib/gitlab/import_export/project_creator.rb
lib/gitlab/import_export/project_creator.rb
+9
-14
No files found.
app/controllers/import/gitlab_projects_controller.rb
View file @
9ecebaae
...
@@ -12,7 +12,7 @@ class Import::GitlabProjectsController < Import::BaseController
...
@@ -12,7 +12,7 @@ class Import::GitlabProjectsController < Import::BaseController
return
redirect_back_or_default
(
options:
{
alert:
"You need to upload a GitLab project export archive."
})
return
redirect_back_or_default
(
options:
{
alert:
"You need to upload a GitLab project export archive."
})
end
end
@project
=
Gitlab
::
GitlabIm
port
::
ProjectCreator
.
new
(
Namespace
.
find
(
project_params
[
:namespace_id
]),
@project
=
Gitlab
::
ImportEx
port
::
ProjectCreator
.
new
(
Namespace
.
find
(
project_params
[
:namespace_id
]),
current_user
,
current_user
,
File
.
expand_path
(
params
[
:file
].
path
),
File
.
expand_path
(
params
[
:file
].
path
),
project_params
[
:path
]).
execute
project_params
[
:path
]).
execute
...
...
app/controllers/projects_controller.rb
View file @
9ecebaae
...
@@ -190,7 +190,7 @@ class ProjectsController < Projects::ApplicationController
...
@@ -190,7 +190,7 @@ class ProjectsController < Projects::ApplicationController
redirect_to
(
redirect_to
(
edit_project_path
(
@project
),
edit_project_path
(
@project
),
notice:
"Project export s
uccessfully s
tarted."
notice:
"Project export started."
)
)
end
end
...
...
app/mailers/emails/projects.rb
View file @
9ecebaae
...
@@ -50,6 +50,19 @@ module Emails
...
@@ -50,6 +50,19 @@ module Emails
subject:
subject
(
"Invitation declined"
))
subject:
subject
(
"Invitation declined"
))
end
end
def
project_was_exported_email
(
current_user
,
project
)
@project
=
project
mail
(
to:
current_user
.
notification_email
,
subject:
subject
(
"Project was exported"
))
end
def
project_was_not_exported_email
(
current_user
,
project
,
errors
)
@project
=
project
@errors
=
errors
mail
(
to:
current_user
.
notification_email
,
subject:
subject
(
"Project export error"
))
end
def
project_was_moved_email
(
project_id
,
user_id
,
old_path_with_namespace
)
def
project_was_moved_email
(
project_id
,
user_id
,
old_path_with_namespace
)
@current_user
=
@user
=
User
.
find
user_id
@current_user
=
@user
=
User
.
find
user_id
@project
=
Project
.
find
project_id
@project
=
Project
.
find
project_id
...
...
app/services/notification_service.rb
View file @
9ecebaae
...
@@ -246,6 +246,14 @@ class NotificationService
...
@@ -246,6 +246,14 @@ class NotificationService
end
end
end
end
def
project_exported
(
project
,
current_user
)
mailer
.
project_was_exported_email
(
current_user
,
project
).
deliver_later
end
def
project_not_exported
(
project
,
current_user
,
errors
)
mailer
.
project_was_not_exported_email
(
current_user
,
project
,
errors
).
deliver_later
end
protected
protected
# Get project users with WATCH notification level
# Get project users with WATCH notification level
...
...
app/services/projects/create_service.rb
View file @
9ecebaae
...
@@ -52,8 +52,6 @@ module Projects
...
@@ -52,8 +52,6 @@ module Projects
save_project_and_import_data
(
import_data
)
save_project_and_import_data
(
import_data
)
@project
.
import_url
=
download_export_namespace_project_path
(
@project
.
namespace
,
@project
)
if
@project
.
gitlab_project_import?
@project
.
import_start
if
@project
.
import?
@project
.
import_start
if
@project
.
import?
after_create_actions
if
@project
.
persisted?
&&
!
@project
.
gitlab_project_import?
after_create_actions
if
@project
.
persisted?
&&
!
@project
.
gitlab_project_import?
...
...
app/services/projects/import_export/export_service.rb
View file @
9ecebaae
...
@@ -12,8 +12,9 @@ module Projects
...
@@ -12,8 +12,9 @@ module Projects
def
save_all
def
save_all
if
[
version_saver
,
project_tree_saver
,
uploads_saver
,
repo_saver
,
wiki_repo_saver
].
all?
(
&
:save
)
if
[
version_saver
,
project_tree_saver
,
uploads_saver
,
repo_saver
,
wiki_repo_saver
].
all?
(
&
:save
)
Gitlab
::
ImportExport
::
Saver
.
save
(
shared:
@shared
)
Gitlab
::
ImportExport
::
Saver
.
save
(
shared:
@shared
)
notify_success
else
else
cleanup_and_notify
_worker
cleanup_and_notify
end
end
end
end
...
@@ -37,10 +38,20 @@ module Projects
...
@@ -37,10 +38,20 @@ module Projects
Gitlab
::
ImportExport
::
WikiRepoSaver
.
new
(
project:
project
,
shared:
@shared
)
Gitlab
::
ImportExport
::
WikiRepoSaver
.
new
(
project:
project
,
shared:
@shared
)
end
end
def
cleanup_and_notify
_worker
def
cleanup_and_notify
FileUtils
.
rm_rf
(
@shared
.
export_path
)
FileUtils
.
rm_rf
(
@shared
.
export_path
)
notify_error
raise
Gitlab
::
ImportExport
::
Error
.
new
(
@shared
.
errors
.
join
(
', '
))
raise
Gitlab
::
ImportExport
::
Error
.
new
(
@shared
.
errors
.
join
(
', '
))
end
end
def
notify_success
notification_service
.
project_exported
(
@project
,
@current_user
)
end
def
notify_error
notification_service
.
project_not_exported
(
@project
,
@current_user
,
@shared
.
errors
.
join
(
', '
))
end
end
end
end
end
end
end
app/views/notify/project_was_exported_email.html.haml
0 → 100644
View file @
9ecebaae
%p
Project
#{
@project
.
name
}
was exported succesfully
%p
The project export can be downloaded from:
=
link_to
download_export_namespace_project_url
(
@project
.
namespace
,
@project
)
do
=
@project
.
name_with_namespace
+
" export"
%p
The download link will expire in 24 hours.
app/views/notify/project_was_exported_email.text.erb
0 → 100644
View file @
9ecebaae
Project
<%=
@project
.
name
%>
was exported succesfully
The project export can be downloaded from:
<%=
download_export_namespace_project_url
(
@project
.
namespace
,
@project
)
%>
The download link will expire in 24 hours.
app/views/notify/project_was_not_exported_email.html.haml
0 → 100644
View file @
9ecebaae
%p
Project
#{
@project
.
name
}
couldn't be exported.
%p
The errors we encountered were:
%h3
{
style:
"background: black; color: red;"
}
#{
@errors
}
app/views/notify/project_was_not_exported_email.text.erb
0 → 100644
View file @
9ecebaae
Project
<%=
@project
.
name
%>
couldn't be exported.
The errors we encountered were:
<%=
@errors
%>
app/workers/project_export_worker.rb
View file @
9ecebaae
...
@@ -7,6 +7,7 @@ class ProjectExportWorker
...
@@ -7,6 +7,7 @@ class ProjectExportWorker
def
perform
(
current_user_id
,
project_id
)
def
perform
(
current_user_id
,
project_id
)
current_user
=
User
.
find
(
current_user_id
)
current_user
=
User
.
find
(
current_user_id
)
project
=
Project
.
find
(
project_id
)
project
=
Project
.
find
(
project_id
)
::
Projects
::
ImportExport
::
ExportService
.
new
(
project
,
current_user
).
execute
::
Projects
::
ImportExport
::
ExportService
.
new
(
project
,
current_user
).
execute
end
end
end
end
lib/gitlab/gitlab_import/project_creator.rb
View file @
9ecebaae
...
@@ -3,21 +3,24 @@ module Gitlab
...
@@ -3,21 +3,24 @@ module Gitlab
class
ProjectCreator
class
ProjectCreator
attr_reader
:repo
,
:namespace
,
:current_user
,
:session_data
attr_reader
:repo
,
:namespace
,
:current_user
,
:session_data
def
initialize
(
namespace_id
,
current_user
,
file
,
project_path
)
def
initialize
(
repo
,
namespace
,
current_user
,
session_data
)
@namespace_id
=
namespace_id
@repo
=
repo
@namespace
=
namespace
@current_user
=
current_user
@current_user
=
current_user
@file
=
file
@session_data
=
session_data
@project_path
=
project_path
end
end
def
execute
def
execute
::
Projects
::
CreateService
.
new
(
::
Projects
::
CreateService
.
new
(
current_user
,
current_user
,
name:
@project_path
,
name:
repo
[
"name"
],
path:
@project_path
,
path:
repo
[
"path"
],
namespace_id:
namespace_id
,
description:
repo
[
"description"
],
import_type:
"gitlab_project"
,
namespace_id:
namespace
.
id
,
import_source:
@file
visibility_level:
repo
[
"visibility_level"
],
import_type:
"gitlab"
,
import_source:
repo
[
"path_with_namespace"
],
import_url:
repo
[
"http_url_to_repo"
].
sub
(
"://"
,
"://oauth2:
#{
@session_data
[
:gitlab_access_token
]
}
@"
)
).
execute
).
execute
end
end
end
end
...
...
lib/gitlab/import_export/project_creator.rb
View file @
9ecebaae
...
@@ -2,26 +2,21 @@ module Gitlab
...
@@ -2,26 +2,21 @@ module Gitlab
module
ImportExport
module
ImportExport
class
ProjectCreator
class
ProjectCreator
def
initialize
(
namespace_id
,
current_user
)
def
initialize
(
namespace_id
,
current_user
,
file
,
project_path
)
@repo
=
repo
@namespace_id
=
namespace_id
@namespace
=
Namespace
.
find_by_id
(
namespace_id
)
@current_user
=
current_user
@current_user
=
current_user
@user_map
=
user_map
@file
=
file
@project_path
=
project_path
end
end
def
execute
def
execute
::
Projects
::
CreateService
.
new
(
::
Projects
::
CreateService
.
new
(
current_user
,
current_user
,
name:
repo
.
name
,
name:
@project_path
,
path:
repo
.
name
,
path:
@project_path
,
description:
repo
.
summary
,
namespace_id:
namespace_id
,
namespace:
namespace
,
import_type:
"gitlab_project"
,
creator:
current_user
,
import_source:
@file
visibility_level:
Gitlab
::
VisibilityLevel
::
PUBLIC
,
import_type:
"google_code"
,
import_source:
repo
.
name
,
import_url:
repo
.
import_url
,
import_data:
{
data:
{
'repo'
=>
repo
.
raw_data
,
'user_map'
=>
user_map
}
}
).
execute
).
execute
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