pass hook configuration through CLI arguments

This commit is contained in:
Jabberwocky238
2026-07-30 01:15:49 -04:00
parent 1e5b0225f5
commit 8d299013f9
4 changed files with 54 additions and 36 deletions
+15 -3
View File
@@ -1,8 +1,20 @@
#!/bin/sh
# Default standalone policy: append the hook invocation and its stdin to a log.
# Integrations can supply another script with simplegit daemon -hook-script.
# Default standalone policy. Optional CLI: --log=/path/to/hooks.log --
log_file=${SIMPLEGIT_HOOK_LOG:-${SIMPLEGIT_REPO_ROOT%/repos}/hooks.log}
log_file=
while [ "$#" -gt 0 ]; do
case "$1" in
--log=*) log_file=${1#--log=}; shift ;;
--log) log_file=$2; shift 2 ;;
--) shift; break ;;
*) break ;;
esac
done
[ "$#" -ge 2 ] || exit 0
if [ -z "$log_file" ]; then
repo_dir=$(pwd -P)
log_file=${repo_dir%/*/*}/hooks.log
fi
{
printf '%s\t%s\t%s' "$(date -u +%Y-%m-%dT%H:%M:%SZ)" "$1" "$2"
shift 2