Skip to content

Instantly share code, notes, and snippets.

@simonc
Created July 20, 2010 14:49
Show Gist options
  • Save simonc/483050 to your computer and use it in GitHub Desktop.
Save simonc/483050 to your computer and use it in GitHub Desktop.
commit-msg
#!/usr/bin/env ruby
file = ARGV.first
branch = `git br --no-color | grep '^*' | cut -d' ' -f2`.gsub(/ref-(\d+)-.*/, '\1').strip
open('/tmp/git_debug', 'a') { |f| f.puts branch }
msg = ''
if branch =~ /^\d+$/s
open(file, 'r') do |f|
msg = f.read
end
unless msg =~ /^Ref #/
open(file, 'w') do |f|
f.puts "Ref ##{branch} : #{msg}"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment