commit 7201734e8b48b6196a0e1089dc442485595add08
parent 2c5dd145cc0bef7948c32dee84712a8606ef4431
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Mon, 26 May 2025 19:03:46 +0200
Install post-receive hook template
Slight update of git-publish to prefer the local file if it exists
before looking for the one installed on the system.
Diffstat:
2 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/Makefile b/Makefile
@@ -33,13 +33,15 @@ install:
install 755 "$(DESTDIR)$(BINPREFIX)" git-publish; \
install 755 "$(DESTDIR)$(BINPREFIX)" git-repo; \
install 644 "$(DESTDIR)$(MANPREFIX)/man1" git-repo.1; \
- install 644 "$(DESTDIR)$(MANPREFIX)/man1" git-publish.1
+ install 644 "$(DESTDIR)$(MANPREFIX)/man1" git-publish.1; \
+ install 644 "$(DESTDIR)/etc/git-repo" post-receive.in
uninstall:
rm -f "$(DESTDIR)$(BINPREFIX)/git-publish"
rm -f "$(DESTDIR)$(BINPREFIX)/git-repo"
rm -f "$(DESTDIR)$(MANPREFIX)/man1/git-repo.1"
rm -f "$(DESTDIR)$(MANPREFIX)/man1/git-publish.1"
+ rm -f "$(DESTDIR)/etc/git-repo/post-receive.in"
lint:
shellcheck -o all git-publish
diff --git a/git-publish b/git-publish
@@ -108,10 +108,18 @@ publish_repo()
# - repo: git bare repository
setup_post_receive_hook()
{
+ # The local template file takes precedence over the installed one
+ if [ -e "post-receive.in" ]; then
+ hook="post-receive.in"
+ else
+ hook="/etc/git-publish/post-receive.in"
+ fi
+
+ # Generate the post-receive script
sed -e "s#@DIR_GIT@#${dir_git}#g" \
-e "s#@DIR_WWW@#${dir_www}#g" \
-e "s#@BASE_URL@#${base_url}#g" \
- post-receive.in > "${tmpdir}/post-receive"
+ "${hook}" > "${tmpdir}/post-receive"
if [ -e "${repo}/hooks/post-receive" ] \
&& ! diff "${repo}/hooks/post-receive" \