SVN Beacon: 1 repository, multiple LH Projects
Hello there,
one question - I have one 'bit' repository which holds all my projects in one place, even though they all have seperate projects in my lighthouse account.
Is it possible to have the proper changesets added to the corresponding projects in lh with just one post-commit hook for that repository?
-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
1 Posted by Rick on 28 May, 2007 12:05 AM
Sure, it's up to your script to figure out which project to send it to though. I've been hacking on the svn beacon example to try and come up with a better solution for it: http://pastie.caboo.se/65167
The yielded config object is a hash where each key should be a regular expression that matches against the change paths, and the value should be a hash of options for the match. I haven't actually set this up just yet, but it looks like it should work :)
2 Posted by Joerg Batterman... on 28 May, 2007 05:32 PM
aww it doesn't :-(
Still trying to figure out why, but when run from the command line like this:
.. it returns the error above and the log file looks like:
.. too.
the whole post-commit-file looks like this now:
#!/opt/csw/bin/ruby require 'yaml' require 'cgi' # configure multiple project settings below def ping_lighthouse(options = {}) config = {} yield config if block_given? commit_dirs_changed = `#{SVNLOOK} dirs-changed #{repo_path} -r #{revision}` config.each do |prefix, prefix_options| if commit_dirs_changed.split(/\n/)[0] =~ prefix options.update(prefix_options) end end return unless options[:account] && options[:project] && options[:token] repo_path = ARGV[0] revision = ARGV[1] 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 token = options[:users][commit_author] || options[:token] url = '%s/projects/%d/changesets.xml?_token=%s' % [options[:account], options[:project], token] cmd = "#{CURL} -H 'Accept: application/xml' -H 'Content-Type: application/xml' -d '#{changeset_xml.gsub(/'/, "\\'").strip}' #{url}" %x{#{cmd}} end begin SVNLOOK = '/opt/csw/bin/svnlook' CURL = '/opt/csw/bin/curl' LOG_FILE = '/tmp/svn-hooks.log' ping_lighthouse :token => 'mytoken', :users => { 'Joerg Battermann' => 'beacon_name' } do |config| config[/^subrepos1\/trunk/] = { :account => 'http://myurl.lighthouseapp.com', :project => 1234, # REPLACE } config[/^subrepos2\/trunk/] = { :account => 'http://myurl.lighthouseapp.com', :project => 1235, # REPLACE } end rescue %x{echo "repo:#{ARGV[0]} rev: #{ARGV[1]}" > #{LOG_FILE}} %x{echo "Error: #{$!} trace:#{caller}" >> #{LOG_FILE}} end3 Posted by Rick on 28 May, 2007 05:48 PM
Doh, see this is why I didn't want to post the code. I hadn't actually ran it yet :)
Above the 'commit = {}' line at the top of the #ping_lighthouse declaration add:
4 Posted by Joerg Batterman... on 28 May, 2007 06:37 PM
Yay - it's working!
(manually - now I just gotta check why the post-commit hook is not being called by svnserve)
5 Posted by Rick on 28 May, 2007 07:36 PM
Cool, thanks for being the guinea pig!