From cd373885c0dd9d2bbfbda6446a678cebe2c19197 Mon Sep 17 00:00:00 2001 From: Dominik Agres Date: Tue, 28 Oct 2025 17:55:31 +0100 Subject: [PATCH] Git hook --- home/.git-templates/hooks/post-checkout | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100755 home/.git-templates/hooks/post-checkout diff --git a/home/.git-templates/hooks/post-checkout b/home/.git-templates/hooks/post-checkout new file mode 100755 index 0000000..ce781e8 --- /dev/null +++ b/home/.git-templates/hooks/post-checkout @@ -0,0 +1,16 @@ +#!/bin/bash + +origin_url=$(git remote get-url origin 2>/dev/null) + +if [[ "$origin_url" == *"github.com"* ]]; then + + user_repo=$(echo "$origin_url" | sed -E 's#.*github.com[:/](.*)\.git#\1#') + gitea_url="git@192.168.0.212:${user_repo}.git" + + if git remote -v | grep -q "$gitea_url"; then + exit 0 + fi + + git remote set-url --add --push origin "$gitea_url" + git remote set-url --add --push origin "$origin_url" +fi