Commit 8b54b7233ef58a2a39da9777dbeab59b4024cc75
1 parent
1c5876eb
Exists in
master
and in
4 other branches
Async perform for add/remove team members
Showing
5 changed files
with
35 additions
and
11 deletions
Show diff stats
app/models/protected_branch.rb
| @@ -22,7 +22,7 @@ class ProtectedBranch < ActiveRecord::Base | @@ -22,7 +22,7 @@ class ProtectedBranch < ActiveRecord::Base | ||
| 22 | after_destroy :update_repository | 22 | after_destroy :update_repository |
| 23 | 23 | ||
| 24 | def update_repository | 24 | def update_repository |
| 25 | - gitolite.update_repository(project) | 25 | + project.update_repository |
| 26 | end | 26 | end |
| 27 | 27 | ||
| 28 | def commit | 28 | def commit |
app/models/users_project.rb
| @@ -82,9 +82,13 @@ class UsersProject < ActiveRecord::Base | @@ -82,9 +82,13 @@ class UsersProject < ActiveRecord::Base | ||
| 82 | users_project.save | 82 | users_project.save |
| 83 | end | 83 | end |
| 84 | end | 84 | end |
| 85 | - Gitlab::Gitolite.new.update_repositories(Project.where(id: project_ids)) | ||
| 86 | end | 85 | end |
| 87 | 86 | ||
| 87 | + GitoliteWorker.perform_async( | ||
| 88 | + :update_repositories, | ||
| 89 | + project_ids | ||
| 90 | + ) | ||
| 91 | + | ||
| 88 | true | 92 | true |
| 89 | rescue | 93 | rescue |
| 90 | false | 94 | false |
| @@ -97,9 +101,13 @@ class UsersProject < ActiveRecord::Base | @@ -97,9 +101,13 @@ class UsersProject < ActiveRecord::Base | ||
| 97 | users_project.skip_git = true | 101 | users_project.skip_git = true |
| 98 | users_project.destroy | 102 | users_project.destroy |
| 99 | end | 103 | end |
| 100 | - Gitlab::Gitolite.new.update_repositories(Project.where(id: project_ids)) | ||
| 101 | end | 104 | end |
| 102 | 105 | ||
| 106 | + GitoliteWorker.perform_async( | ||
| 107 | + :update_repositories, | ||
| 108 | + project_ids | ||
| 109 | + ) | ||
| 110 | + | ||
| 103 | true | 111 | true |
| 104 | rescue | 112 | rescue |
| 105 | false | 113 | false |
lib/gitlab/backend/gitolite.rb
| @@ -22,7 +22,12 @@ module Gitlab | @@ -22,7 +22,12 @@ module Gitlab | ||
| 22 | end | 22 | end |
| 23 | end | 23 | end |
| 24 | 24 | ||
| 25 | - def update_repository project_id | 25 | + # Update project config in gitolite by project id |
| 26 | + # | ||
| 27 | + # Ex. | ||
| 28 | + # update_repository(23) | ||
| 29 | + # | ||
| 30 | + def update_repository(project_id) | ||
| 26 | project = Project.find(project_id) | 31 | project = Project.find(project_id) |
| 27 | config.update_project!(project) | 32 | config.update_project!(project) |
| 28 | end | 33 | end |
| @@ -45,6 +50,19 @@ module Gitlab | @@ -45,6 +50,19 @@ module Gitlab | ||
| 45 | config.destroy_project!(name) | 50 | config.destroy_project!(name) |
| 46 | end | 51 | end |
| 47 | 52 | ||
| 53 | + # Update projects configs in gitolite by project ids | ||
| 54 | + # | ||
| 55 | + # Ex. | ||
| 56 | + # update_repositories([1, 4, 6]) | ||
| 57 | + # | ||
| 58 | + def update_repositories(project_ids) | ||
| 59 | + projects = Project.where(id: project_ids) | ||
| 60 | + | ||
| 61 | + config.apply do |config| | ||
| 62 | + config.update_projects(projects) | ||
| 63 | + end | ||
| 64 | + end | ||
| 65 | + | ||
| 48 | def url_to_repo path | 66 | def url_to_repo path |
| 49 | Gitlab.config.gitolite.ssh_path_prefix + "#{path}.git" | 67 | Gitlab.config.gitolite.ssh_path_prefix + "#{path}.git" |
| 50 | end | 68 | end |
| @@ -53,12 +71,6 @@ module Gitlab | @@ -53,12 +71,6 @@ module Gitlab | ||
| 53 | config.admin_all_repo! | 71 | config.admin_all_repo! |
| 54 | end | 72 | end |
| 55 | 73 | ||
| 56 | - def update_repositories projects | ||
| 57 | - config.apply do |config| | ||
| 58 | - config.update_projects(projects) | ||
| 59 | - end | ||
| 60 | - end | ||
| 61 | - | ||
| 62 | alias_method :create_repository, :update_repository | 74 | alias_method :create_repository, :update_repository |
| 63 | end | 75 | end |
| 64 | end | 76 | end |
spec/lib/gitolite_spec.rb
| @@ -20,6 +20,6 @@ describe Gitlab::Gitolite do | @@ -20,6 +20,6 @@ describe Gitlab::Gitolite do | ||
| 20 | 20 | ||
| 21 | it "should call config update" do | 21 | it "should call config update" do |
| 22 | gitolite_config.should_receive(:update_project!) | 22 | gitolite_config.should_receive(:update_project!) |
| 23 | - gitolite.update_repository project | 23 | + gitolite.update_repository(project.id) |
| 24 | end | 24 | end |
| 25 | end | 25 | end |