From 68deb8e3bda83a84acfe192392a66ecba19cece6 Mon Sep 17 00:00:00 2001 From: Leo Famulari Date: Wed, 28 May 2025 12:31:23 -0400 Subject: [PATCH] etc: pre-push Git hook: Reduce code duplication. * etc/git/pre-push (perform_checks): New function. Change-Id: Ieff1e2c225e3720c96c75ca55abfb883dd386f5c --- etc/git/pre-push | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/etc/git/pre-push b/etc/git/pre-push index 19c344d91ed..c876b1b6a34 100755 --- a/etc/git/pre-push +++ b/etc/git/pre-push @@ -23,6 +23,14 @@ # This is the "empty hash" used by Git when pushing a branch deletion. z40=0000000000000000000000000000000000000000 +perform_checks() { + set -e + guix git authenticate + exec make check-channel-news + exit 127 +} + +main() { while read local_ref local_hash remote_ref remote_hash do # When deleting a remote branch, no commits are pushed to the remote, and @@ -39,16 +47,10 @@ do # Only use the hook when pushing to upstream. case "$2" in *.gnu.org*) - set -e - guix git authenticate - exec make check-channel-news - exit 127 + perform_checks ;; *codeberg.org/guix/*) - set -e - guix git authenticate - exec make check-channel-news - exit 127 + perform_checks ;; *) exit 0 @@ -58,3 +60,6 @@ do done exit 0 +} + +main "$@"