Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
add refs #xxx to commit message
#!/usr/bin/env ruby
message_file = ARGV[0]
message =
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 #"), "w") do |file|
file.write message
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment