Browse Source

Add update-git-hooks

cryobry 1 year ago
parent
commit
1270a64fb6
1 changed files with 21 additions and 0 deletions
  1. 21 0
      update-git-hooks

+ 21 - 0
update-git-hooks

@@ -0,0 +1,21 @@
+#!/usr/bin/env bash
+#
+# This script will update the post-receive hooks of multiple bare git repos
+#
+#
+
+for i in /var/lib/git/gogs-repositories/bryan/*/hooks/post-receive; do
+
+    # Get repo name
+    rn="${i%/hooks/post-receive}"
+    rn="${rn##*/}"
+
+    # Don't duplicate the line if it already exists
+    while IFS= read -r line; do
+        [[ "$line" == "git push --mirror git@github.com:cryobry/${rn}" ]] && continue
+    done < "$i"
+
+    # Append the line
+    #echo "git push --mirror git@github.com:cryobry/${rn} to $i"
+    echo "git push --mirror git@github.com:cryobry/${rn}" >> "$i"
+done