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
iv
gitlab-ce
Commits
233eb1c6
Commit
233eb1c6
authored
May 25, 2013
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename repo feature
parent
7ef1c99d
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
48 additions
and
3 deletions
+48
-3
app/controllers/application_controller.rb
app/controllers/application_controller.rb
+1
-1
app/controllers/projects_controller.rb
app/controllers/projects_controller.rb
+2
-2
app/models/project.rb
app/models/project.rb
+24
-0
app/observers/project_observer.rb
app/observers/project_observer.rb
+1
-0
app/views/projects/edit.html.haml
app/views/projects/edit.html.haml
+20
-0
No files found.
app/controllers/application_controller.rb
View file @
233eb1c6
...
...
@@ -69,7 +69,7 @@ class ApplicationController < ActionController::Base
@project
else
@project
=
nil
render_404
render_404
and
return
end
end
...
...
app/controllers/projects_controller.rb
View file @
233eb1c6
...
...
@@ -33,12 +33,12 @@ class ProjectsController < ProjectResourceController
end
def
update
status
=
::
Projects
::
UpdateContext
.
new
(
project
,
current_user
,
params
).
execute
status
=
::
Projects
::
UpdateContext
.
new
(
@
project
,
current_user
,
params
).
execute
respond_to
do
|
format
|
if
status
flash
[
:notice
]
=
'Project was successfully updated.'
format
.
html
{
redirect_to
edit_project_path
(
project
),
notice:
'Project was successfully updated.'
}
format
.
html
{
redirect_to
edit_project_path
(
@
project
),
notice:
'Project was successfully updated.'
}
format
.
js
else
format
.
html
{
render
action:
"edit"
}
...
...
app/models/project.rb
View file @
233eb1c6
...
...
@@ -423,4 +423,28 @@ class Project < ActiveRecord::Base
def
forked?
!
(
forked_project_link
.
nil?
||
forked_project_link
.
forked_from_project
.
nil?
)
end
def
rename_repo
old_path_with_namespace
=
File
.
join
(
namespace_dir
,
path_was
)
new_path_with_namespace
=
File
.
join
(
namespace_dir
,
path
)
if
gitlab_shell
.
mv_repository
(
old_path_with_namespace
,
new_path_with_namespace
)
# If repository moved successfully we need to remove old satellite
# and send update instructions to users.
# However we cannot allow rollback since we moved repository
# So we basically we mute exceptions in next actions
begin
gitlab_shell
.
rm_satellites
(
old_path_with_namespace
)
send_move_instructions
rescue
# Returning false does not rolback after_* transaction but gives
# us information about failing some of tasks
false
end
else
# if we cannot move namespace directory we should rollback
# db changes in order to prevent out of sync between db and fs
raise
Exception
.
new
(
'repository cannot be renamed'
)
end
end
end
app/observers/project_observer.rb
View file @
233eb1c6
...
...
@@ -12,6 +12,7 @@ class ProjectObserver < BaseObserver
def
after_update
(
project
)
project
.
send_move_instructions
if
project
.
namespace_id_changed?
project
.
rename_repo
if
project
.
path_changed?
end
def
after_destroy
(
project
)
...
...
app/views/projects/edit.html.haml
View file @
233eb1c6
...
...
@@ -10,6 +10,8 @@
%ul
.nav.nav-pills.nav-stacked
%li
.active
=
link_to
'Settings'
,
'#tab-settings'
,
'data-toggle'
=>
'tab'
%li
=
link_to
'Rename repo'
,
'#tab-rename'
,
'data-toggle'
=>
'tab'
%li
=
link_to
'Transfer'
,
'#tab-transfer'
,
'data-toggle'
=>
'tab'
%li
...
...
@@ -137,6 +139,24 @@
-
else
%p
.nothing_here_message
Only project owner can transfer a project
.tab-pane
#tab-rename
.ui-box.ui-box-danger
%h5
.title
Rename repository
.errors-holder
.form-holder
=
form_for
(
@project
)
do
|
f
|
.control-group
=
f
.
label
:path
do
%span
Path
.controls
.clearfix
=
f
.
text_field
:path
%ul
%li
Be careful. Rename of project repo can have unintended side effects
%li
You will need to update your local repositories to point to the new location.
.form-actions
=
f
.
submit
'Rename'
,
class:
"btn btn-remove"
.tab-pane
#tab-remove
-
if
can?
(
current_user
,
:remove_project
,
@project
)
.ui-box.ui-box-danger
...
...
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