Post-Commit Hook not working on Joyent Accelerator

Joerg Battermann's Avatar

Joerg Battermann

15 Apr, 2007 06:22 PM

Hello there,

I have a subversion repository running on our joyent accelerator (solaris) which works perfectly fine via apache2 etc, but for some reason the post-commit hook below does not do anything :(

its chmod'ed to +x for the apache user (nobody):

total 55
drwxrwxrwx   2 nobody   nobody        12 Apr 15 13:00 ./
drwxrwxrwx   7 nobody   nobody         9 Apr 14 14:06 ../
-rwxrwxrwx   1 nobody   nobody      1.9K Apr 15 18:14 post-commit*
-rw-rw-rw-   1 nobody   nobody      2.0K Apr 14 14:06 post-commit.tmpl
-rw-rw-rw-   1 nobody   nobody      1.6K Apr 14 14:06 post-lock.tmpl
-rw-rw-rw-   1 nobody   nobody      2.2K Apr 14 14:06 post-revprop-change.tmpl
-rw-rw-rw-   1 nobody   nobody      1.5K Apr 14 14:06 post-unlock.tmpl
-rw-rw-rw-   1 nobody   nobody      2.9K Apr 14 14:06 pre-commit.tmpl
-rw-rw-rw-   1 nobody   nobody      2.0K Apr 14 14:06 pre-lock.tmpl
-rw-rw-rw-   1 nobody   nobody      2.7K Apr 14 14:06 pre-revprop-change.tmpl
-rw-rw-rw-   1 nobody   nobody      1.9K Apr 14 14:06 pre-unlock.tmpl
-rw-rw-rw-   1 nobody   nobody      2.1K Apr 14 14:06 start-commit.tmpl

.. but for some reason nothing's happening after a commit on lighthouse :(

Here's the content of the file:


#!/opt/csw/bin/ruby
require 'yaml'
require 'cgi'

# configure multiple project settings below
SVNLOOK    = '/opt/csw/bin/svnlook'
CURL       = '/opt/csw/bin/curl'
LOG_FILE   = '/tmp/svn-hooks.log'

def gather_and_post(repo_path, revision, options)
  if options[:prefix]
    commit_dirs_changed = `#{SVNLOOK} dirs-changed #{repo_path} -r 
#{revision}`
    return unless commit_dirs_changed.split(/\n/)[0] =~ options[:prefix]
  end

  commit_author  = `#{SVNLOOK} author #{repo_path} -r #{revision}`.chop
  commit_log     = `#{SVNLOOK} log #{repo_path} -r #{revision}`
  commit_date    = `#{SVNLOOK} date #{repo_path} -r #{revision}`
  commit_changed = `#{SVNLOOK} changed #{repo_path} -r #{revision}`

  commit_changes = commit_changed.split("\n").inject([]) do |memo, line| 
    if line.strip =~ /(\w)\s+(.*)/
      memo << [$1, $2]
    end
  end.to_yaml

  changeset_xml = <
    #{CGI.escapeHTML("%s committed changeset [%d]" % 
[commit_author, revision])}
    #{CGI.escapeHTML(commit_log)}
    #{CGI.escapeHTML(commit_changes)}
    #{CGI.escapeHTML(revision.to_s)}
    #{CGI.escapeHTML(commit_date.split('(').first.strip)}
  
END_XML

  url = '%s/projects/%d/changesets.xml?_token=%s' % [options[:account], 
options[:project], options[:token]]
  cmd = "#{CURL} -H 'Accept: application/xml' -H 'Content-Type: 
application/xml' -d '#{changeset_xml.gsub(/'/, "\\'").strip}' #{url}"
  %x{#{cmd}}
end

begin
  # feel free to add multiple calls below
  gather_and_post ARGV[0], ARGV[1],
    :token   => '66d0ca',
    :account => 'http://justbe.lighthouseapp.com',
    :project => '572-justbe-com', # REPLACE
    :prefix  => /^trunk/ # OPTIONAL
rescue
  %x{echo "repo:#{ARGV[0]} rev: #{ARGV[1]}" > #{LOG_FILE}}
  %x{echo "Error: #{$!} trace:#{caller}" >> #{LOG_FILE}}
end

Any ideas / suggestions why?

Thanks, -Joerg

  1. 1 Posted by Rick on 15 Apr, 2007 07:51 PM

    Rick's Avatar

    Try running it manually. @ruby post-commit@ or whatever the filename is.

  2. 2 Posted by Joerg Batterman... on 15 Apr, 2007 09:34 PM

    Joerg Battermann's Avatar

    Yep that solved it - there were some linebreaks in it that shouldn't be there.... :)

    It's working now.. thanks for the little push.

    -J

Discussions are closed to public comments.
If you need help with Lighthouse please start a new discussion.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac