summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeo Famulari <leo@famulari.name>2025-05-28 12:31:23 -0400
committerLeo Famulari <leo@famulari.name>2025-05-28 12:43:44 -0400
commit5bac84e248a462ae5d44b4a1c44e9a186394e5d2 (patch)
tree97333e5d1fe09510581bacaccbc0dd69169e2fc1
parentee8144743dedc67c4d92f5f900a539ef328b2e21 (diff)
etc: pre-push Git hook: Reduce code duplication.wip-hook
* etc/git/pre-push (guix_git_authenticate): New function. Change-Id: Ieff1e2c225e3720c96c75ca55abfb883dd386f5c
-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..51c400e42e 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
+guix_git_authenticate() {
+ 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
+ guix_git_authenticate
;;
*codeberg.org/guix/*)
- set -e
- guix git authenticate
- exec make check-channel-news
- exit 127
+ guix_git_authenticate
;;
*)
exit 0
@@ -58,3 +60,6 @@ do
done
exit 0
+}
+
+main "$@"