etc: pre-push Git hook: Reduce code duplication.

* etc/git/pre-push (perform_checks): New function.

Change-Id: Ieff1e2c225e3720c96c75ca55abfb883dd386f5c
This commit is contained in:
Leo Famulari 2025-05-28 12:31:23 -04:00
parent 8e122651d9
commit 68deb8e3bd
No known key found for this signature in database
GPG key ID: 6AAC1963757F47FF

View file

@ -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 "$@"