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
11f46b45
Commit
11f46b45
authored
Apr 13, 2016
by
Felipe Artur
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Setup visibility level for project when transfering for a group
parent
f026e53c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
4 deletions
+41
-4
app/services/projects/transfer_service.rb
app/services/projects/transfer_service.rb
+17
-4
app/views/projects/edit.html.haml
app/views/projects/edit.html.haml
+1
-0
spec/services/projects/transfer_service_spec.rb
spec/services/projects/transfer_service_spec.rb
+23
-0
No files found.
app/services/projects/transfer_service.rb
View file @
11f46b45
...
...
@@ -34,9 +34,12 @@ module Projects
raise
TransferError
.
new
(
"Project with same path in target namespace already exists"
)
end
# Apply new namespace id
project
.
namespace
=
new_namespace
project
.
save!
# Apply new namespace id and visibility level
project
.
tap
do
|
p
|
p
.
namespace
=
new_namespace
setup_visibility_level
(
p
,
new_namespace
)
p
.
save!
end
# Notifications
project
.
send_move_instructions
(
old_path
)
...
...
@@ -56,7 +59,7 @@ module Projects
Gitlab
::
UploadsTransfer
.
new
.
move_project
(
project
.
path
,
old_namespace
.
path
,
new_namespace
.
path
)
project
.
old_path_with_namespace
=
old_path
SystemHooksService
.
new
.
execute_hooks_for
(
project
,
:transfer
)
true
end
...
...
@@ -68,5 +71,15 @@ module Projects
namespace
.
id
!=
project
.
namespace_id
&&
current_user
.
can?
(
:create_projects
,
namespace
)
end
private
def
setup_visibility_level
(
project
,
new_namespace
)
return
unless
new_namespace
.
is_a?
(
Group
)
if
project
.
visibility_level
>
new_namespace
.
visibility_level
project
.
visibility_level
=
new_namespace
.
visibility_level
end
end
end
end
app/views/projects/edit.html.haml
View file @
11f46b45
...
...
@@ -210,6 +210,7 @@
%li
Be careful. Changing the project's namespace can have unintended side effects.
%li
You can only transfer the project to namespaces you manage.
%li
You will need to update your local repositories to point to the new location.
%li
Project visibility level will be changed to match namespace rules when transfering to a group.
.form-actions
=
f
.
submit
'Transfer project'
,
class:
"btn btn-remove js-confirm-danger"
,
data:
{
"confirm-danger-message"
=>
transfer_project_message
(
@project
)
}
-
else
...
...
spec/services/projects/transfer_service_spec.rb
View file @
11f46b45
...
...
@@ -38,4 +38,27 @@ describe Projects::TransferService, services: true do
def
transfer_project
(
project
,
user
,
new_namespace
)
Projects
::
TransferService
.
new
(
project
,
user
).
execute
(
new_namespace
)
end
context
'visibility level'
do
let
(
:internal_group
)
{
create
(
:group
,
:internal
)
}
before
{
internal_group
.
add_owner
(
user
)
}
context
'when namespace visibility level < project visibility level'
do
let
(
:public_project
)
{
create
(
:project
,
:public
,
namespace:
user
.
namespace
)
}
before
{
transfer_project
(
public_project
,
user
,
internal_group
)
}
it
{
expect
(
public_project
.
visibility_level
).
to
eq
(
internal_group
.
visibility_level
)
}
end
context
'when namespace visibility level > project visibility level'
do
let
(
:private_project
)
{
create
(
:project
,
:private
,
namespace:
user
.
namespace
)
}
before
{
transfer_project
(
private_project
,
user
,
internal_group
)
}
it
{
expect
(
private_project
.
visibility_level
).
to
eq
(
Gitlab
::
VisibilityLevel
::
PRIVATE
)
}
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