Skip to content

Instantly share code, notes, and snippets.

Created December 18, 2012 19:52
Show Gist options
  • Save anonymous/4331310 to your computer and use it in GitHub Desktop.
Save anonymous/4331310 to your computer and use it in GitHub Desktop.
prepare-commit-msg
#!/usr/bin/env ruby
branch_name = `git rev-parse --abbrev-ref HEAD`
branch_number_regex = /^(\d+)/
matcher = branch_name.match(branch_number_regex)
branch_number = matcher[1]
if branch_number
path = ARGV[0]
contents = File.read path
contents = " [##{branch_number}]" + contents
File.open(path, 'w+') do |f|
f.write contents
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment