#!/usr/bin/perl -w # git pre-receive hook for SBo. # checks commit message formats, aborts push if any are bad. # 20261123 bkw: initial version. may still need work. # 20261123 bkw: added colors and -o mono, add test env instructions. ########################################################################### # How to set up a testing environment for this # # 1. Create a bare git repo: # git clone --bare git://git.slackbuilds.org/slackbuilds.git ~/sbo.bare # # 2. Copy this file to the bare repo and make it executable: # cp /path/to/pre-receive ~/sbo.bare/hooks # chmod +x ~/sbo.bare/hooks/pre-receive # # 3. Enable this config option in the bare repo: # cd ~/sbo.bare # git config receive.advertisePushOptions true # # 4. Go to your regular git work dir, and create some commits with # deliberately bad messages. Leave off the category, make them # longer than the 68-character limit, etc. # # 5. Try to push these commits to your bare repo: # git push ~/sbo.bare # # 6. You should see error messages complaining about the bad commits, # and the push should be rejected. # # 7. You can see verbose debug info from this hook by doing this: # git push -o debug ~/sbo.bare # ########################################################################### # This is a "server side" hook. Installing it your regular worktree's # .git/hooks/ won't do anything. # This hook looks for "invalid" commit messages. # A valid message looks like [1]: # category/build: Message. # Where: # - The overall length must be <= 68 characters. # - Category is one of the top-level dirs in the git repo [2]. # - Build consists only of upper/lowercase letters, numbers, # underscore, dash, period, or plus characters. # - A single colon and space are required after the build. # - The message can be anything. # - Ideally, there should be a period (dot, full stop, ".") at # the end of the message, but this script doesn't enforce that, # since sometimes it has to be left out to squeeze the message in to # 68 chars. # [1] A message beginning with "Public www update" is considered valid, # since this is standard for weekly updates. # [2] "git" is accepted as a category as well, since it's used for # changes to the CI system. ### options # Push options are supported, using "git push -o