Skip to content

Instantly share code, notes, and snippets.

@pulkitsinghal
Forked from nicoverbruggen/commit-msg
Last active August 29, 2015 14:26
Show Gist options
  • Save pulkitsinghal/f9c6eac2329604d45e3c to your computer and use it in GitHub Desktop.
Save pulkitsinghal/f9c6eac2329604d45e3c to your computer and use it in GitHub Desktop.
Git hook that checks if you reference an issue in your commit
#!/usr/bin/env ruby
message_file = ARGV[0]
message = File.read(message_file)
$regex = /issues?\s+#(\d+)/
if !$regex.match(message)
puts "[POLICY] Please reference an issue in your commit."
exit 1
end
@pulkitsinghal
Copy link
Author

Tested on rubular.com with sample inputs:

issue # 4
issue#4
s #4
issue #4
issues #4
issues  #4
issue  #4
what have we here an issue  #4 mayhap?
what have we here an issue mayhap #4 mayhap?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment