Commit bc0155fbaa1261f348324c1ddf5d1eaba5907f77
1 parent
1c9b9b7a
Exists in
master
and in
4 other branches
First attempt at a post-receive hook that posts directly to Resque
Showing
5 changed files
with
30 additions
and
14 deletions
Show diff stats
app/models/repository.rb
| ... | ... | @@ -31,6 +31,17 @@ class Repository |
| 31 | 31 | project.id |
| 32 | 32 | end |
| 33 | 33 | |
| 34 | + # repo.update_hook('post-receive', File.read('some-hook')) | |
| 35 | + def update_hook(name, content) | |
| 36 | + hook_file = File.join(project.path_to_repo, 'hooks', name) | |
| 37 | + | |
| 38 | + File.open(hook_file, 'w') do |f| | |
| 39 | + f.write(content) | |
| 40 | + end | |
| 41 | + | |
| 42 | + File.chmod(0775, hook_file) | |
| 43 | + end | |
| 44 | + | |
| 34 | 45 | def repo |
| 35 | 46 | @repo ||= Grit::Repo.new(project.path_to_repo) |
| 36 | 47 | end | ... | ... |
db/schema.rb
| ... | ... | @@ -13,18 +13,6 @@ |
| 13 | 13 | |
| 14 | 14 | ActiveRecord::Schema.define(:version => 20111207211728) do |
| 15 | 15 | |
| 16 | - create_table "features", :force => true do |t| | |
| 17 | - t.string "name" | |
| 18 | - t.string "branch_name" | |
| 19 | - t.integer "assignee_id" | |
| 20 | - t.integer "author_id" | |
| 21 | - t.integer "project_id" | |
| 22 | - t.datetime "created_at" | |
| 23 | - t.datetime "updated_at" | |
| 24 | - t.string "version" | |
| 25 | - t.integer "status", :default => 0, :null => false | |
| 26 | - end | |
| 27 | - | |
| 28 | 16 | create_table "issues", :force => true do |t| |
| 29 | 17 | t.string "title" |
| 30 | 18 | t.integer "assignee_id" | ... | ... |
lib/gitlabhq/gitolite.rb
| ... | ... | @@ -43,14 +43,14 @@ module Gitlabhq |
| 43 | 43 | |
| 44 | 44 | def destroy_project(project) |
| 45 | 45 | FileUtils.rm_rf(project.path_to_repo) |
| 46 | - | |
| 46 | + | |
| 47 | 47 | ga_repo = ::Gitolite::GitoliteAdmin.new(File.join(@local_dir,'gitolite')) |
| 48 | 48 | conf = ga_repo.config |
| 49 | 49 | conf.rm_repo(project.path) |
| 50 | 50 | ga_repo.save |
| 51 | 51 | end |
| 52 | 52 | |
| 53 | - #update or create | |
| 53 | + #update or create | |
| 54 | 54 | def update_keys(user, key) |
| 55 | 55 | File.open(File.join(@local_dir, 'gitolite/keydir',"#{user}.pub"), 'w') {|f| f.write(key.gsub(/\n/,'')) } |
| 56 | 56 | end | ... | ... |
| ... | ... | @@ -0,0 +1,12 @@ |
| 1 | +#!/bin/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\"]}" > /dev/null 2>&1 | |
| 12 | +done | ... | ... |