Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Git hook for adding issue numbers to commits
#!/usr/bin/env ruby
filename = ARGV[0]
branch_name = `git rev-parse --abbrev-ref HEAD`
issue = branch_name[/^[A-Z]+-\d+/]
if issue
contents =
File.write(filename, "#{ issue }:\n#{ contents }")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment