From 616e10be3af507a747de3e288c4b2a18191ffb9e Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Tue, 24 Nov 2026 01:32:48 -0500 Subject: pre-receive: added. --- README | 4 + pre-receive | 316 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 320 insertions(+) create mode 100755 pre-receive diff --git a/README b/README index 5522b82..8fee27e 100644 --- a/README +++ b/README @@ -42,6 +42,10 @@ Included tools: incomplete, and not yet installed by "make install". Use it at your own peril. +- pre-receive: A git hook that's installed on the SBo git server. It's + a "server-side" hook, so it's not that useful anywhere else, but + it's included here for reference. + Note that the SBo admins use sbolint and sbopkglint as part of the approval process, when you submit an update. Failure to pass the lint checks is a valid reason for rejecting your submission, so you should diff --git a/pre-receive b/pre-receive new file mode 100755 index 0000000..4cba932 --- /dev/null +++ b/pre-receive @@ -0,0 +1,316 @@ +#!/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