Project -> update repo only on create and destroy. Fixtures Updated with namespaces. Fixed moving repo
This commit is contained in:
parent
cc52eed981
commit
70bf7f6e19
11 changed files with 45 additions and 31 deletions
|
@ -36,7 +36,7 @@ class ProjectsController < ProjectResourceController
|
|||
def update
|
||||
namespace_id = params[:project].delete(:namespace_id)
|
||||
|
||||
if namespace_id
|
||||
if namespace_id.present? and namespace_id.to_i != project.namespace_id
|
||||
namespace = Namespace.find(namespace_id)
|
||||
project.transfer(namespace)
|
||||
end
|
||||
|
|
|
@ -27,6 +27,7 @@ class Namespace < ActiveRecord::Base
|
|||
|
||||
after_create :ensure_dir_exist
|
||||
after_update :move_dir
|
||||
after_destroy :rm_dir
|
||||
|
||||
scope :root, where('type IS NULL')
|
||||
|
||||
|
@ -52,4 +53,9 @@ class Namespace < ActiveRecord::Base
|
|||
new_path = File.join(Gitlab.config.git_base_path, path)
|
||||
system("mv #{old_path} #{new_path}")
|
||||
end
|
||||
|
||||
def rm_dir
|
||||
dir_path = File.join(Gitlab.config.git_base_path, path)
|
||||
system("rm -rf #{dir_path}")
|
||||
end
|
||||
end
|
||||
|
|
|
@ -254,6 +254,10 @@ class Project < ActiveRecord::Base
|
|||
old_dir = old_namespace.try(:path) || ''
|
||||
new_dir = new_namespace.try(:path) || ''
|
||||
|
||||
old_repo = File.join(old_dir, self.path)
|
||||
|
||||
git_host.move_repository(old_repo, self.path_with_namespace, self)
|
||||
|
||||
Gitlab::ProjectMover.new(self, old_dir, new_dir).execute
|
||||
|
||||
save!
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
class ProjectObserver < ActiveRecord::Observer
|
||||
def after_save(project)
|
||||
def after_create(project)
|
||||
project.update_repository
|
||||
end
|
||||
|
||||
def after_save(project)
|
||||
end
|
||||
|
||||
def after_destroy(project)
|
||||
log_info("Project \"#{project.name}\" was removed")
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
%title
|
||||
GitLab
|
||||
:css
|
||||
.header h1 {color: #BBBBBB !important; font: bold 32px Helvetica, Arial, sans-serif; margin: 0; padding: 0; line-height: 40px;}
|
||||
.header h1 {color: #BBBBBB !important; font: bold 22px Helvetica, Arial, sans-serif; margin: 0; padding: 0; line-height: 32px;}
|
||||
.header p {color: #c6c6c6; font: normal 12px Helvetica, Arial, sans-serif; margin: 0; padding: 0; line-height: 18px;}
|
||||
.content h2 {color:#646464 !important; font-weight: bold; margin: 0; padding: 0; line-height: 26px; font-size: 18px; font-family: Helvetica, Arial, sans-serif; }
|
||||
.content p {color:#767676; font-weight: normal; margin: 0; padding: 0; line-height: 20px; font-size: 12px;font-family: Helvetica, Arial, sans-serif;}
|
||||
|
@ -35,5 +35,5 @@
|
|||
%p{style: "font-size: 11px; color:#7d7a7a; margin: 0; padding: 0; font-family: Helvetica, Arial, sans-serif;"}
|
||||
You're receiving this notification because you are a member of the
|
||||
- if @project
|
||||
#{@project.name}
|
||||
#{@project.name}
|
||||
project team.
|
||||
|
|
|
@ -13,15 +13,15 @@
|
|||
%legend Advanced settings:
|
||||
.control-group
|
||||
= f.label :path do
|
||||
Path
|
||||
Repository
|
||||
.controls
|
||||
= text_field_tag :ppath, @project.path_to_repo, class: "xlarge", disabled: true
|
||||
= text_field_tag :ppath, @project.path_to_repo, class: "xxlarge", readonly: true
|
||||
|
||||
.control-group
|
||||
= f.label :namespace_id do
|
||||
%span Namespace
|
||||
.controls
|
||||
= f.select :namespace_id, namespaces_options(@project.namespace_id), {}, {class: 'chosen'}
|
||||
= f.select :namespace_id, namespaces_options(@project.namespace_id), {prompt: 'Choose a project namespace'}, {class: 'chosen'}
|
||||
|
||||
%span.cred Be careful. Changing project namespace can have unintended side effects
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue