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
Boxiang Sun
gitlab-ce
Commits
b9305369
Commit
b9305369
authored
Jul 02, 2015
by
Douwe Maan
Committed by
Robert Speicher
Jul 11, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix transferring of project to another group using the API.
parent
f94587ec
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
15 additions
and
15 deletions
+15
-15
CHANGELOG
CHANGELOG
+1
-0
app/controllers/admin/projects_controller.rb
app/controllers/admin/projects_controller.rb
+2
-1
app/controllers/projects_controller.rb
app/controllers/projects_controller.rb
+5
-4
app/services/projects/transfer_service.rb
app/services/projects/transfer_service.rb
+5
-8
lib/api/groups.rb
lib/api/groups.rb
+2
-2
No files found.
CHANGELOG
View file @
b9305369
...
@@ -48,6 +48,7 @@ v 7.12.2
...
@@ -48,6 +48,7 @@ v 7.12.2
- Correctly show anonymous authorized applications under Profile > Applications.
- Correctly show anonymous authorized applications under Profile > Applications.
- Faster automerge check and merge itself when source and target branches are in same repository
- Faster automerge check and merge itself when source and target branches are in same repository
- Audit log for user authentication
- Audit log for user authentication
- Fix transferring of project to another group using the API.
v 7.12.1
v 7.12.1
- Fix error when deleting a user who has projects (Stan Hu)
- Fix error when deleting a user who has projects (Stan Hu)
...
...
app/controllers/admin/projects_controller.rb
View file @
b9305369
...
@@ -23,7 +23,8 @@ class Admin::ProjectsController < Admin::ApplicationController
...
@@ -23,7 +23,8 @@ class Admin::ProjectsController < Admin::ApplicationController
end
end
def
transfer
def
transfer
::
Projects
::
TransferService
.
new
(
@project
,
current_user
,
params
.
dup
).
execute
namespace
=
Namespace
.
find_by
(
id:
params
[
:new_namespace_id
])
::
Projects
::
TransferService
.
new
(
@project
,
current_user
,
params
.
dup
).
execute
(
namespace
)
@project
.
reload
@project
.
reload
redirect_to
admin_namespace_project_path
(
@project
.
namespace
,
@project
)
redirect_to
admin_namespace_project_path
(
@project
.
namespace
,
@project
)
...
...
app/controllers/projects_controller.rb
View file @
b9305369
...
@@ -52,10 +52,11 @@ class ProjectsController < ApplicationController
...
@@ -52,10 +52,11 @@ class ProjectsController < ApplicationController
end
end
def
transfer
def
transfer
transfer_params
=
params
.
permit
(
:new_namespace_id
)
namespace
=
Namespace
.
find_by
(
id:
params
[
:new_namespace_id
])
::
Projects
::
TransferService
.
new
(
project
,
current_user
,
transfer_params
).
execute
::
Projects
::
TransferService
.
new
(
project
,
current_user
).
execute
(
namespace
)
if
@project
.
errors
[
:namespace_id
].
present?
flash
[
:alert
]
=
@project
.
errors
[
:namespace_id
].
first
if
@project
.
errors
[
:new_namespace
].
present?
flash
[
:alert
]
=
@project
.
errors
[
:new_namespace
].
first
end
end
end
end
...
...
app/services/projects/transfer_service.rb
View file @
b9305369
...
@@ -11,19 +11,16 @@ module Projects
...
@@ -11,19 +11,16 @@ module Projects
include
Gitlab
::
ShellAdapter
include
Gitlab
::
ShellAdapter
class
TransferError
<
StandardError
;
end
class
TransferError
<
StandardError
;
end
def
execute
def
execute
(
new_namespace
)
namespace_id
=
params
[
:new_namespace_id
]
if
allowed_transfer?
(
current_user
,
project
,
new_namespace
)
namespace
=
Namespace
.
find_by
(
id:
namespace_id
)
transfer
(
project
,
new_namespace
)
if
allowed_transfer?
(
current_user
,
project
,
namespace
)
transfer
(
project
,
namespace
)
else
else
project
.
errors
.
add
(
:namespace
,
'is invalid'
)
project
.
errors
.
add
(
:n
ew_n
amespace
,
'is invalid'
)
false
false
end
end
rescue
Projects
::
TransferService
::
TransferError
=>
ex
rescue
Projects
::
TransferService
::
TransferError
=>
ex
project
.
reload
project
.
reload
project
.
errors
.
add
(
:n
amespace_id
,
ex
.
message
)
project
.
errors
.
add
(
:n
ew_namespace
,
ex
.
message
)
false
false
end
end
...
...
lib/api/groups.rb
View file @
b9305369
...
@@ -74,9 +74,9 @@ module API
...
@@ -74,9 +74,9 @@ module API
# POST /groups/:id/projects/:project_id
# POST /groups/:id/projects/:project_id
post
":id/projects/:project_id"
do
post
":id/projects/:project_id"
do
authenticated_as_admin!
authenticated_as_admin!
group
=
Group
.
find
(
params
[
:id
])
group
=
Group
.
find
_by
(
id:
params
[
:id
])
project
=
Project
.
find
(
params
[
:project_id
])
project
=
Project
.
find
(
params
[
:project_id
])
result
=
::
Projects
::
TransferService
.
new
(
project
,
current_user
,
namespace_id:
group
.
id
).
execute
result
=
::
Projects
::
TransferService
.
new
(
project
,
current_user
).
execute
(
group
)
if
result
if
result
present
group
present
group
...
...
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