Skip to content

Commit

Permalink
#62: Add pre-commit hook to inspect commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
dgroup committed Jan 30, 2022
1 parent 302c1bf commit 68edd99
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions .githooks/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env ruby

def check_message_format
regex = /^#\d+:\s\w+/
message_file = ARGV[0]
message = File.read(message_file)
unless regex.match(message)
puts "Your commit message is not formatted correctly"
puts "Message should have following format: '#issue_id: Commit message'"
puts "How to fix: https://github.com/k88hudson/git-flight-rules#i-wrote-the-wrong-thing-in-a-commit-message"
exit 1
end
end

check_message_format

0 comments on commit 68edd99

Please sign in to comment.