Skip to content

Instantly share code, notes, and snippets.

@texel
Forked from anonymous/prepare-commit-msg.rb
Created December 18, 2012 20:36
Show Gist options
  • Save texel/4331732 to your computer and use it in GitHub Desktop.
Save texel/4331732 to your computer and use it in GitHub Desktop.
#!/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