public
Created

add refs #xxx to commit message

  • Download Gist
prepare-commit-msg
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
#!/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

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.