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
app/models/users_project.rb
... | ... | @@ -82,9 +82,13 @@ class UsersProject < ActiveRecord::Base |
82 | 82 | users_project.save |
83 | 83 | end |
84 | 84 | end |
85 | - Gitlab::Gitolite.new.update_repositories(Project.where(id: project_ids)) | |
86 | 85 | end |
87 | 86 | |
87 | + GitoliteWorker.perform_async( | |
88 | + :update_repositories, | |
89 | + project_ids | |
90 | + ) | |
91 | + | |
88 | 92 | true |
89 | 93 | rescue |
90 | 94 | false |
... | ... | @@ -97,9 +101,13 @@ class UsersProject < ActiveRecord::Base |
97 | 101 | users_project.skip_git = true |
98 | 102 | users_project.destroy |
99 | 103 | end |
100 | - Gitlab::Gitolite.new.update_repositories(Project.where(id: project_ids)) | |
101 | 104 | end |
102 | 105 | |
106 | + GitoliteWorker.perform_async( | |
107 | + :update_repositories, | |
108 | + project_ids | |
109 | + ) | |
110 | + | |
103 | 111 | true |
104 | 112 | rescue |
105 | 113 | false | ... | ... |
lib/gitlab/backend/gitolite.rb
... | ... | @@ -22,7 +22,12 @@ module Gitlab |
22 | 22 | end |
23 | 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 | 31 | project = Project.find(project_id) |
27 | 32 | config.update_project!(project) |
28 | 33 | end |
... | ... | @@ -45,6 +50,19 @@ module Gitlab |
45 | 50 | config.destroy_project!(name) |
46 | 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 | 66 | def url_to_repo path |
49 | 67 | Gitlab.config.gitolite.ssh_path_prefix + "#{path}.git" |
50 | 68 | end |
... | ... | @@ -53,12 +71,6 @@ module Gitlab |
53 | 71 | config.admin_all_repo! |
54 | 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 | 74 | alias_method :create_repository, :update_repository |
63 | 75 | end |
64 | 76 | end | ... | ... |
spec/lib/gitolite_spec.rb