Last active
December 29, 2015 05:39
-
-
Save paolocarrasco/7623895 to your computer and use it in GitHub Desktop.
A *commit-msg git hook* where I ask to enter the issue number, the Github usernames and then the description of the commit.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# Github usernames may only contain alphanumeric characters | |
# or dashes and cannot begin with a dash | |
$regex = /^(?:(?:fixes|closes|resolves)\s)?#\d+\s\[@[a-z0-9][a-z0-9\-]*(?:,\s@[a-z0-9][a-z0-9\-]*)*\]\s(?:\w+[\.\,]?\s)+/i | |
message_file = ARGV[0] | |
message = File.read(message_file) | |
if !$regex.match(message) | |
puts '[POLICY]' | |
puts '* Your message is not formatted correctly' | |
puts '* It should follow the pattern:' | |
puts '* #<issue number> [<github usernames>] commit description' | |
exit 1 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment