Commit c625293b995cf21a1b551cecaac3cb742fcb2e66
1 parent
2e7ca8c8
Exists in
master
and in
4 other branches
Handle post-receive files via gitolite, not gitlab
Showing
8 changed files
with
41 additions
and
58 deletions
Show diff stats
app/roles/repository.rb
... | ... | @@ -30,26 +30,10 @@ module Repository |
30 | 30 | Commit.commits_between(repo, from, to) |
31 | 31 | end |
32 | 32 | |
33 | - def write_hooks | |
34 | - %w(post-receive).each do |hook| | |
35 | - write_hook(hook, File.read(File.join(Rails.root, 'lib', "#{hook}-hook"))) | |
36 | - end | |
37 | - end | |
38 | - | |
39 | 33 | def satellite |
40 | 34 | @satellite ||= Gitlab::Satellite.new(self) |
41 | 35 | end |
42 | 36 | |
43 | - def write_hook(name, content) | |
44 | - hook_file = File.join(path_to_repo, 'hooks', name) | |
45 | - | |
46 | - File.open(hook_file, 'w') do |f| | |
47 | - f.write(content) | |
48 | - end | |
49 | - | |
50 | - File.chmod(0775, hook_file) | |
51 | - end | |
52 | - | |
53 | 37 | def has_post_receive_file? |
54 | 38 | hook_file = File.join(path_to_repo, 'hooks', 'post-receive') |
55 | 39 | File.exists?(hook_file) |
... | ... | @@ -73,8 +57,6 @@ module Repository |
73 | 57 | |
74 | 58 | def update_repository |
75 | 59 | Gitlab::GitHost.system.update_project(path, self) |
76 | - | |
77 | - write_hooks if File.exists?(path_to_repo) | |
78 | 60 | end |
79 | 61 | |
80 | 62 | def destroy_repository | ... | ... |
app/views/errors/gitolite.html.haml
... | ... | @@ -0,0 +1,12 @@ |
1 | +#!/usr/bin/env bash | |
2 | + | |
3 | +# This file was placed here by Gitlab. It makes sure that your pushed commits | |
4 | +# will be processed properly. | |
5 | + | |
6 | +while read oldrev newrev ref | |
7 | +do | |
8 | + # For every branch or tag that was pushed, create a Resque job in redis. | |
9 | + pwd=`pwd` | |
10 | + reponame=`basename "$pwd" | cut -d. -f1` | |
11 | + env -i redis-cli rpush "resque:queue:post_receive" "{\"class\":\"PostReceive\",\"args\":[\"$reponame\",\"$oldrev\",\"$newrev\",\"$ref\",\"$GL_USER\"]}" > /dev/null 2>&1 | |
12 | +done | ... | ... |
lib/post-receive-hook
... | ... | @@ -1,12 +0,0 @@ |
1 | -#!/usr/bin/env bash | |
2 | - | |
3 | -# This file was placed here by Gitlab. It makes sure that your pushed commits | |
4 | -# will be processed properly. | |
5 | - | |
6 | -while read oldrev newrev ref | |
7 | -do | |
8 | - # For every branch or tag that was pushed, create a Resque job in redis. | |
9 | - pwd=`pwd` | |
10 | - reponame=`basename "$pwd" | cut -d. -f1` | |
11 | - env -i redis-cli rpush "resque:queue:post_receive" "{\"class\":\"PostReceive\",\"args\":[\"$reponame\",\"$oldrev\",\"$newrev\",\"$ref\",\"$GL_USER\"]}" > /dev/null 2>&1 | |
12 | -done |
lib/tasks/gitlab/setup.rake
1 | 1 | namespace :gitlab do |
2 | 2 | namespace :app do |
3 | 3 | desc "GITLAB | Setup production application" |
4 | - task :setup => ['db:setup', 'db:seed_fu', 'gitlab:app:enable_automerge'] | |
4 | + task :setup => [ | |
5 | + 'db:setup', | |
6 | + 'db:seed_fu', | |
7 | + 'gitlab:gitolite:write_hooks', | |
8 | + 'gitlab:app:enable_automerge' | |
9 | + ] | |
5 | 10 | end |
6 | 11 | end |
7 | 12 | ... | ... |
lib/tasks/gitlab/status.rake
lib/tasks/gitlab/update_hooks.rake
... | ... | @@ -1,19 +0,0 @@ |
1 | -namespace :gitlab do | |
2 | - namespace :gitolite do | |
3 | - desc "GITLAB | Rewrite hooks for repos" | |
4 | - task :update_hooks => :environment do | |
5 | - puts "Starting Projects" | |
6 | - Project.find_each(:batch_size => 100) do |project| | |
7 | - begin | |
8 | - if project.commit | |
9 | - project.write_hooks | |
10 | - print ".".green | |
11 | - end | |
12 | - rescue Exception => e | |
13 | - print e.message.red | |
14 | - end | |
15 | - end | |
16 | - puts "\nDone with projects" | |
17 | - end | |
18 | - end | |
19 | -end |
... | ... | @@ -0,0 +1,23 @@ |
1 | +namespace :gitlab do | |
2 | + namespace :gitolite do | |
3 | + desc "GITLAB | Write GITLAB hook for gitolite" | |
4 | + task :write_hooks => :environment do | |
5 | + gitolite_hooks_path = File.join("/home", Gitlab.config.ssh_user, "share", "gitolite", "hooks", "common") | |
6 | + gitlab_hooks_path = Rails.root.join("lib", "hooks") | |
7 | + | |
8 | + gitlab_hook_files = ['post-receive'] | |
9 | + | |
10 | + gitlab_hook_files.each do |file_name| | |
11 | + source = File.join(gitlab_hooks_path, file_name) | |
12 | + dest = File.join(gitolite_hooks_path, file_name) | |
13 | + | |
14 | + puts "sudo -u root cp #{source} #{dest}".yellow | |
15 | + `sudo -u root cp #{source} #{dest}` | |
16 | + | |
17 | + puts "sudo -u root chown git:git #{dest}".yellow | |
18 | + `sudo -u root chown git:git #{dest}` | |
19 | + end | |
20 | + end | |
21 | + end | |
22 | +end | |
23 | + | ... | ... |