Skip to content

Instantly share code, notes, and snippets.

@aalin
Last active October 16, 2015 14:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save aalin/6a5f1a8fceb12c2e39a8 to your computer and use it in GitHub Desktop.
Save aalin/6a5f1a8fceb12c2e39a8 to your computer and use it in GitHub Desktop.
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