Commit 8b54b723 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Async perform for add/remove team members

parent 1c5876eb
...@@ -22,7 +22,7 @@ class ProtectedBranch < ActiveRecord::Base ...@@ -22,7 +22,7 @@ class ProtectedBranch < ActiveRecord::Base
after_destroy :update_repository after_destroy :update_repository
def update_repository def update_repository
gitolite.update_repository(project) project.update_repository
end end
def commit def commit
......
...@@ -82,9 +82,13 @@ class UsersProject < ActiveRecord::Base ...@@ -82,9 +82,13 @@ class UsersProject < ActiveRecord::Base
users_project.save users_project.save
end end
end end
Gitlab::Gitolite.new.update_repositories(Project.where(id: project_ids))
end end
GitoliteWorker.perform_async(
:update_repositories,
project_ids
)
true true
rescue rescue
false false
...@@ -97,9 +101,13 @@ class UsersProject < ActiveRecord::Base ...@@ -97,9 +101,13 @@ class UsersProject < ActiveRecord::Base
users_project.skip_git = true users_project.skip_git = true
users_project.destroy users_project.destroy
end end
Gitlab::Gitolite.new.update_repositories(Project.where(id: project_ids))
end end
GitoliteWorker.perform_async(
:update_repositories,
project_ids
)
true true
rescue rescue
false false
......
...@@ -22,7 +22,12 @@ module Gitlab ...@@ -22,7 +22,12 @@ module Gitlab
end end
end end
def update_repository project_id # Update project config in gitolite by project id
#
# Ex.
# update_repository(23)
#
def update_repository(project_id)
project = Project.find(project_id) project = Project.find(project_id)
config.update_project!(project) config.update_project!(project)
end end
...@@ -45,6 +50,19 @@ module Gitlab ...@@ -45,6 +50,19 @@ module Gitlab
config.destroy_project!(name) config.destroy_project!(name)
end end
# Update projects configs in gitolite by project ids
#
# Ex.
# update_repositories([1, 4, 6])
#
def update_repositories(project_ids)
projects = Project.where(id: project_ids)
config.apply do |config|
config.update_projects(projects)
end
end
def url_to_repo path def url_to_repo path
Gitlab.config.gitolite.ssh_path_prefix + "#{path}.git" Gitlab.config.gitolite.ssh_path_prefix + "#{path}.git"
end end
...@@ -53,12 +71,6 @@ module Gitlab ...@@ -53,12 +71,6 @@ module Gitlab
config.admin_all_repo! config.admin_all_repo!
end end
def update_repositories projects
config.apply do |config|
config.update_projects(projects)
end
end
alias_method :create_repository, :update_repository alias_method :create_repository, :update_repository
end end
end end
...@@ -20,6 +20,6 @@ describe Gitlab::Gitolite do ...@@ -20,6 +20,6 @@ describe Gitlab::Gitolite do
it "should call config update" do it "should call config update" do
gitolite_config.should_receive(:update_project!) gitolite_config.should_receive(:update_project!)
gitolite.update_repository project gitolite.update_repository(project.id)
end end
end end
...@@ -21,6 +21,10 @@ class Project ...@@ -21,6 +21,10 @@ class Project
true true
end end
def destroy
true
end
def create def create
true true
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment