Skip to content

Instantly share code, notes, and snippets.

Embed
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.read(filename)
File.write(filename, "#{ issue }:\n#{ contents }")
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment