Skip to content

Instantly share code, notes, and snippets.

@thegeorgeous
Created April 23, 2019 10:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thegeorgeous/cdf59119b92cf77fd624ef9e09bedea2 to your computer and use it in GitHub Desktop.
Save thegeorgeous/cdf59119b92cf77fd624ef9e09bedea2 to your computer and use it in GitHub Desktop.
Commit hook to pick the ticket number from branch name and append it to git log summary
#!/usr/bin/env ruby
branch_name = `git symbolic-ref --short HEAD`
if !File.read(ARGV[0]).match?(/fixup!|squash!|\[WIP\]|\[\d+\]/) && branch_name.match?(/\d+/)
story_number = branch_name.match(/\d+/)[0]
if story_number
lines = File.readlines(ARGV[0])
lines[0] = "[#{story_number}] " + lines[0]
File.open(ARGV[0], 'w') { |f| f.write(lines.join) }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment