summaryrefslogtreecommitdiff
path: root/etc
diff options
context:
space:
mode:
authorLeo Famulari <leo@famulari.name>2025-05-28 12:31:23 -0400
committerLeo Famulari <leo@famulari.name>2025-05-30 17:14:34 -0400
commit68deb8e3bda83a84acfe192392a66ecba19cece6 (patch)
treeb6eb9c82f75505b43b0b8e0fc69da6db25ac7bff /etc
parent8e122651d95e775fce589b008ed83a16aeaae9e0 (diff)
etc: pre-push Git hook: Reduce code duplication.
* etc/git/pre-push (perform_checks): New function. Change-Id: Ieff1e2c225e3720c96c75ca55abfb883dd386f5c
Diffstat (limited to 'etc')
-rwxr-xr-xetc/git/pre-push21
1 files changed, 13 insertions, 8 deletions
diff --git a/etc/git/pre-push b/etc/git/pre-push
index 19c344d91e..c876b1b6a3 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 "$@"