diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2012-11-21 08:54:05 +0300 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2012-11-21 08:54:05 +0300 |
commit | 70bf7f6e191c0e99ad03e1eec2ecbe2aae53fa09 (patch) | |
tree | 9ff90fbd30aa5386a543b770b0566aebb599b698 /app | |
parent | cc52eed9816edb513482ec0db428e46c0bdce4c5 (diff) | |
download | gitlab-ce-70bf7f6e191c0e99ad03e1eec2ecbe2aae53fa09.tar.gz |
Project -> update repo only on create and destroy. Fixtures Updated with namespaces. Fixed moving repo
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/projects_controller.rb | 2 | ||||
-rw-r--r-- | app/models/namespace.rb | 6 | ||||
-rw-r--r-- | app/models/project.rb | 4 | ||||
-rw-r--r-- | app/observers/project_observer.rb | 5 | ||||
-rw-r--r-- | app/views/layouts/notify.html.haml | 4 | ||||
-rw-r--r-- | app/views/projects/_form.html.haml | 6 |
6 files changed, 20 insertions, 7 deletions
diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 1a402efa7c4..37b47adeba9 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -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 diff --git a/app/models/namespace.rb b/app/models/namespace.rb index 013660406af..8eae36db8e2 100644 --- a/app/models/namespace.rb +++ b/app/models/namespace.rb @@ -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 diff --git a/app/models/project.rb b/app/models/project.rb index 4874dd14d8e..707f8286ef8 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -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! diff --git a/app/observers/project_observer.rb b/app/observers/project_observer.rb index 03a61709829..bd41e51e8e4 100644 --- a/app/observers/project_observer.rb +++ b/app/observers/project_observer.rb @@ -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") diff --git a/app/views/layouts/notify.html.haml b/app/views/layouts/notify.html.haml index 7b79897b653..8cfe1982316 100644 --- a/app/views/layouts/notify.html.haml +++ b/app/views/layouts/notify.html.haml @@ -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. diff --git a/app/views/projects/_form.html.haml b/app/views/projects/_form.html.haml index fe926adbceb..5c60132cc82 100644 --- a/app/views/projects/_form.html.haml +++ b/app/views/projects/_form.html.haml @@ -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 |