Skip to content

Instantly share code, notes, and snippets.

@ujh
Created April 1, 2011 08:01
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ujh/897867 to your computer and use it in GitHub Desktop.
Save ujh/897867 to your computer and use it in GitHub Desktop.
git commit hook that modifies the commit message to include links to Pivotal Tracker stories when issue number is included
#!/usr/bin/env ruby
PREFIX = "https://www.pivotaltracker.com/story/show/"
fn = ARGV.first
sids = []
File.open(fn) do |f|
f.each do |line|
next if line =~ /^#/
line.scan(/\[[^#]*#(\d+)\s*\]/) {|a| sids += a }
end
end
story_links = sids.map {|i| PREFIX + i }.join("\n")
msg = File.read(fn) + "\n" + story_links
File.open(fn, 'w') {|f| f.puts msg }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment