Skip to content

Instantly share code, notes, and snippets.

@landtax
Created May 24, 2012 12:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save landtax/2781374 to your computer and use it in GitHub Desktop.
Save landtax/2781374 to your computer and use it in GitHub Desktop.
add refs #xxx to commit message
#!/usr/bin/env ruby
message_file = ARGV[0]
message = File.read(message_file)
branch = `git branch`.scan(/\* (.*)/).flatten[0]
exit 0 if branch == "master"
issue_no = branch.scan(/(\d{3,})/).flatten[0]
exit 0 if issue_no.nil?
message = "#refs ##{issue_no} \n" + message unless message.match("refs #")
File.open(message_file, "w") do |file|
file.write message
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment