diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2013-02-04 17:07:56 +0400 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2013-02-04 17:07:56 +0400 |
commit | 27d9ac0fe8a33f0e94178c1f46826bc114e16467 (patch) | |
tree | acfb46c9189213045c893dfe7ad35be211e483e0 /app | |
parent | 6b9a60904451fb192e445774768ccb53f7f8d2f8 (diff) |
Make gitlab works with gitlab-shell
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/application_controller.rb | 5 | ||||
-rw-r--r-- | app/models/key.rb | 4 | ||||
-rw-r--r-- | app/models/project.rb | 14 | ||||
-rw-r--r-- | app/models/users_project.rb | 7 | ||||
-rw-r--r-- | app/observers/key_observer.rb | 12 | ||||
-rw-r--r-- | app/observers/project_observer.rb | 16 |
6 files changed, 19 insertions, 39 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index ca2a5623f42..1f211bac9c2 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -10,11 +10,6 @@ class ApplicationController < ActionController::Base helper_method :abilities, :can? - rescue_from Gitlab::Gitolite::AccessDenied do |exception| - log_exception(exception) - render "errors/gitolite", layout: "errors", status: 500 - end - rescue_from Encoding::CompatibilityError do |exception| log_exception(exception) render "errors/encoding", layout: "errors", status: 500 diff --git a/app/models/key.rb b/app/models/key.rb index 2bf50f56565..f1c9e42f04f 100644 --- a/app/models/key.rb +++ b/app/models/key.rb @@ -80,4 +80,8 @@ class Key < ActiveRecord::Base def last_deploy? Key.where(identifier: identifier).count == 0 end + + def owner_name + user.username + end end diff --git a/app/models/project.rb b/app/models/project.rb index 6a3d7ab15d2..e774949ed12 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -459,20 +459,6 @@ class Project < ActiveRecord::Base namespace.try(:path) || '' end - def update_repository - GitoliteWorker.perform_async( - :update_repository, - self.id - ) - end - - def destroy_repository - GitoliteWorker.perform_async( - :remove_repository, - self.path_with_namespace - ) - end - def repo_exists? @repo_exists ||= (repository && repository.branches.present?) rescue diff --git a/app/models/users_project.rb b/app/models/users_project.rb index 94edfd9eddf..359db20000b 100644 --- a/app/models/users_project.rb +++ b/app/models/users_project.rb @@ -25,9 +25,6 @@ class UsersProject < ActiveRecord::Base attr_accessor :skip_git - after_save :update_repository, unless: :skip_git? - after_destroy :update_repository, unless: :skip_git? - validates :user, presence: true validates :user_id, uniqueness: { scope: [:project_id], message: "already exists in project" } validates :project_access, inclusion: { in: [GUEST, REPORTER, DEVELOPER, MASTER] }, presence: true @@ -136,10 +133,6 @@ class UsersProject < ActiveRecord::Base end end - def update_repository - project.update_repository - end - def project_access_human Project.access_options.key(self.project_access) end diff --git a/app/observers/key_observer.rb b/app/observers/key_observer.rb index 44e78643d83..261e2245b97 100644 --- a/app/observers/key_observer.rb +++ b/app/observers/key_observer.rb @@ -3,20 +3,16 @@ class KeyObserver < ActiveRecord::Observer def after_save(key) GitoliteWorker.perform_async( - :set_key, - key.identifier, - key.key, - key.projects.map(&:id) + :add_key, + key.owner_name, + key.key ) end def after_destroy(key) - return if key.is_deploy_key && !key.last_deploy? - GitoliteWorker.perform_async( :remove_key, - key.identifier, - key.projects.map(&:id) + key.key, ) end end diff --git a/app/observers/project_observer.rb b/app/observers/project_observer.rb index ccdb146140b..32004503fbf 100644 --- a/app/observers/project_observer.rb +++ b/app/observers/project_observer.rb @@ -1,6 +1,11 @@ class ProjectObserver < ActiveRecord::Observer def after_create(project) - project.update_repository + GitoliteWorker.perform_async( + :add_repository, + project.path_with_namespace + ) + + log_info("#{project.owner.name} created a new project \"#{project.name_with_namespace}\"") end def after_update(project) @@ -8,14 +13,15 @@ class ProjectObserver < ActiveRecord::Observer end def after_destroy(project) - log_info("Project \"#{project.name}\" was removed") + GitoliteWorker.perform_async( + :remove_repository, + self.path_with_namespace + ) project.satellite.destroy project.destroy_repository - end - def after_create project - log_info("#{project.owner.name} created a new project \"#{project.name_with_namespace}\"") + log_info("Project \"#{project.name}\" was removed") end protected |