summaryrefslogtreecommitdiffstats
path: root/data
diff options
context:
space:
mode:
authorDavid A. Cuadrado <krawek@gmail.com>2008-03-10 14:23:18 -0500
committerDavid A. Cuadrado <krawek@gmail.com>2008-03-20 16:32:01 -0500
commit0925f6160fda4ad4d98bf8e68bd7ead976743ccb (patch)
tree818b395436c4c391721cdb0e31991347c427ab50 /data
parent3f8987a2971ec32690b2b854c9a64935f2f31f09 (diff)
downloadgitorious-mainline-outdated-0925f6160fda4ad4d98bf8e68bd7ead976743ccb.zip
gitorious-mainline-outdated-0925f6160fda4ad4d98bf8e68bd7ead976743ccb.tar.gz
gitorious-mainline-outdated-0925f6160fda4ad4d98bf8e68bd7ead976743ccb.tar.bz2
Load rails environment
Diffstat (limited to 'data')
-rw-r--r--data/hooks/git.rb77
-rwxr-xr-xdata/hooks/post-receive10
-rw-r--r--data/hooks/rails_env.rb10
3 files changed, 16 insertions, 81 deletions
diff --git a/data/hooks/git.rb b/data/hooks/git.rb
deleted file mode 100644
index 5427003..0000000
--- a/data/hooks/git.rb
+++ /dev/null
@@ -1,77 +0,0 @@
-module Grit
- class << self; attr_accessor :debug end
-# self.debug = true
- class Git
- undef_method :clone
-
- class << self
- attr_accessor :git_binary
- end
-
- self.git_binary = "/usr/bin/env git"
-
- attr_accessor :git_dir
-
- def initialize(git_dir)
- self.git_dir = git_dir
- end
-
- def execute(command)
- `#{command}`
- end
-
- # Run the given git command with the specified arguments and return
- # the result as a String
- # +cmd+ is the command
- # +options+ is a hash of Ruby style options
- # +args+ is the list of arguments (to be joined by spaces)
- #
- # Examples
- # git.rev_list({:max_count => 10, :header => true}, "master")
- #
- # Returns String
- def method_missing(cmd, options = {}, *args)
- opt_args = transform_options(options)
- ext_args = args.map { |a| (a == '--' or a =~ /^\s*\|/) ? a : "'#{e(a)}'" }
-
- call = "#{Git.git_binary} --git-dir='#{self.git_dir}' #{cmd.to_s.gsub(/_/, '-')} #{(opt_args + ext_args).join(' ')}"
- puts call if Grit.debug
- response = execute(call)
- puts response if Grit.debug
- response
- end
-
- def shell_escape(str)
- str.to_s.gsub("'", "\\\\'")
- end
- alias_method :e, :shell_escape
-
- # Transform Ruby style options into git command line options
- # +options+ is a hash of Ruby style options
- #
- # Returns String[]
- # e.g. ["--max-count=10", "--header"]
- def transform_options(options)
- args = []
- options.keys.each do |opt|
- if opt.to_s.size == 1
- if options[opt] == true
- args << "-#{opt}"
- else
- val = options.delete(opt)
- args << "-#{opt.to_s} '#{e(val)}'"
- end
- else
- if options[opt] == true
- args << "--#{opt.to_s.gsub(/_/, '-')}"
- else
- val = options.delete(opt)
- args << "--#{opt.to_s.gsub(/_/, '-')}='#{e(val)}'"
- end
- end
- end
- args
- end
- end # Git
-
-end # Grit
diff --git a/data/hooks/post-receive b/data/hooks/post-receive
index 540169f..32b4ef5 100755
--- a/data/hooks/post-receive
+++ b/data/hooks/post-receive
@@ -1,13 +1,15 @@
#!/usr/bin/env ruby
-$: << File.dirname(__FILE__)
-require 'git'
+incpath = File.dirname(__FILE__)
+$: << incpath
+
+require 'rails_env'
require 'date'
-gitdir = File.expand_path(File.join(File.dirname(__FILE__), ".."))
+gitdir = File.expand_path(File.join(incpath, ".."))
slug = File.basename(gitdir)
-if slug == "mainline.git"
+if slug =~ /\.git$/
slug = File.basename(File.expand_path(File.join(gitdir, "..")))
end
diff --git a/data/hooks/rails_env.rb b/data/hooks/rails_env.rb
new file mode 100644
index 0000000..1abb544
--- /dev/null
+++ b/data/hooks/rails_env.rb
@@ -0,0 +1,10 @@
+
+current_dir = File.expand_path(File.dirname(__FILE__))
+app_root = File.join(current_dir, "../../")
+
+print "=> Wait... "
+$stdout.flush
+ENV["RAILS_ENV"] ||= "production"
+require File.join(app_root,"/config/environment")
+
+puts "[OK]"