githooks

Personal git hooks
git clone git://pollux.codes/git/githooks.git
Log | Files | Refs | README

commit d204c0553042b1fe46a2610489ecb77f8c03e834
parent fea8ec7d275a3618482988e5f961016256c05232
Author: Pollux <pollux@pollux.codes>
Date:   Mon, 10 Feb 2025 01:17:16 -0600

feat: Add hook installer

Signed-off-by: Pollux <pollux@pollux.codes>

Diffstat:
AMakefile | 7+++++++
Agithook | 16++++++++++++++++
2 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/Makefile b/Makefile @@ -0,0 +1,7 @@ +PWD=$(shell pwd) +PREFIX="$(HOME)/.local/bin" + +all: githook + @echo "Installing githook to $(PREFIX)/githook" + @cat githook | sed "s#%HOOKSDIR%#$(PWD)#" > $(PREFIX)/githook + @chmod +x $(PREFIX)/githook diff --git a/githook b/githook @@ -0,0 +1,16 @@ +#!/bin/sh + +HOOKSDIR="%HOOKSDIR%" + +if [ ! -d '.git/hooks' ]; then + echo "No hooks directory found, are you in a git repo?" + exit 1 +fi + +for var in "$@"; do + echo "Installing $var hooks... " + cp $HOOKSDIR/$var/* ".git/hooks" +done + +echo "Installing shared hooks... " +cp $HOOKSDIR/shared/* ".git/hooks"