diff --git a/app/models/repository.rb b/app/models/repository.rb index 0e6f0e9a8f9..61fcf0cb79e 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -31,6 +31,17 @@ class Repository project.id end + # repo.update_hook('post-receive', File.read('some-hook')) + def update_hook(name, content) + hook_file = File.join(project.path_to_repo, 'hooks', name) + + File.open(hook_file, 'w') do |f| + f.write(content) + end + + File.chmod(0775, hook_file) + end + def repo @repo ||= Grit::Repo.new(project.path_to_repo) end diff --git a/app/workers/post_receive.rb b/app/workers/post_receive.rb new file mode 100644 index 00000000000..01620f7818a --- /dev/null +++ b/app/workers/post_receive.rb @@ -0,0 +1,5 @@ +class PostReceive + def self.perform(reponame, oldrev, newrev, ref) + puts "[#{reponame}] #{oldrev} => #{newrev} (#{ref})" + end +end diff --git a/db/schema.rb b/db/schema.rb index 17246a614f8..613b65cb2ad 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -13,18 +13,6 @@ ActiveRecord::Schema.define(:version => 20111207211728) do - create_table "features", :force => true do |t| - t.string "name" - t.string "branch_name" - t.integer "assignee_id" - t.integer "author_id" - t.integer "project_id" - t.datetime "created_at" - t.datetime "updated_at" - t.string "version" - t.integer "status", :default => 0, :null => false - end - create_table "issues", :force => true do |t| t.string "title" t.integer "assignee_id" diff --git a/lib/gitlabhq/gitolite.rb b/lib/gitlabhq/gitolite.rb index e79afb55577..f3d8584f014 100644 --- a/lib/gitlabhq/gitolite.rb +++ b/lib/gitlabhq/gitolite.rb @@ -43,14 +43,14 @@ module Gitlabhq def destroy_project(project) FileUtils.rm_rf(project.path_to_repo) - + ga_repo = ::Gitolite::GitoliteAdmin.new(File.join(@local_dir,'gitolite')) conf = ga_repo.config conf.rm_repo(project.path) ga_repo.save end - #update or create + #update or create def update_keys(user, key) File.open(File.join(@local_dir, 'gitolite/keydir',"#{user}.pub"), 'w') {|f| f.write(key.gsub(/\n/,'')) } end diff --git a/lib/post-receive-hook b/lib/post-receive-hook new file mode 100755 index 00000000000..ec7c607f75d --- /dev/null +++ b/lib/post-receive-hook @@ -0,0 +1,12 @@ +#!/bin/bash + +# This file was placed here by Gitlab. It makes sure that your pushed commits +# will be processed properly. + +while read oldrev newrev ref +do + # For every branch or tag that was pushed, create a Resque job in redis. + pwd=`pwd` + reponame=`basename "$pwd" | cut -d. -f1` + env -i redis-cli rpush "resque:queue:post-receive" "{\"class\":\"PostReceive\",\"args\":[\"$reponame\",\"$oldrev\",\"$newrev\",\"$ref\"]}" > /dev/null 2>&1 +done