Skip to content

Instantly share code, notes, and snippets.

@aalin
Created July 15, 2011 08:28
Show Gist options
  • Select an option

  • Save aalin/1084318 to your computer and use it in GitHub Desktop.

Select an option

Save aalin/1084318 to your computer and use it in GitHub Desktop.
git commit-msg hook that replaces STORYID with the story id from the branch name (s-123, s123, t123, t-123)
#!/usr/bin/env ruby
if match = `git symbolic-ref HEAD 2> /dev/null`.split('/').last.to_s.match(/^(?:t|s)-?(\d+)$/)
message = File.read(ARGV.first)
message.gsub!("STORYID", "[##{ match[1] }]")
File.open(ARGV.first, 'w') do |f|
f.puts(message)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment