Skip to content

Instantly share code, notes, and snippets.

@arnklint
Forked from aalin/prepare-commit-msg
Created October 16, 2015 14:28
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 arnklint/c403080e6daf6eeb925d to your computer and use it in GitHub Desktop.
Save arnklint/c403080e6daf6eeb925d 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