From 188e281d68579729667422d744e2cb32d4b2648a Mon Sep 17 00:00:00 2001 From: Debian Date: Thu, 28 Aug 2025 14:36:04 +0000 Subject: [PATCH] =?UTF-8?q?[skip=20ci]=20chore(sync):=20maj=20hooks+doc=20?= =?UTF-8?q?agents=20centralis=C3=A9s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/scripts/auto-ssh-push.sh | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/scripts/scripts/auto-ssh-push.sh b/scripts/scripts/auto-ssh-push.sh index 5294e0a8..a813ec5a 100755 --- a/scripts/scripts/auto-ssh-push.sh +++ b/scripts/scripts/auto-ssh-push.sh @@ -26,8 +26,23 @@ fi echo "✅ Authentification SSH réussie" # Fonction pour push automatique +get_current_branch() { + # Détecte la branche courante, compatible anciennes versions de git + local br + br="$(git rev-parse --abbrev-ref HEAD 2>/dev/null || true)" + if [ -z "$br" ] || [ "$br" = "HEAD" ]; then + br="$(git symbolic-ref --short -q HEAD 2>/dev/null || true)" + fi + if [ -z "$br" ]; then + # dernier recours: parser la sortie de "git branch" + br="$(git branch 2>/dev/null | sed -n 's/^* //p' | head -n1)" + fi + echo "$br" +} + auto_push() { - local branch=${1:-$(git branch --show-current)} + local branch + branch=${1:-$(get_current_branch)} local commit_message=${2:-"Auto-commit $(date '+%Y-%m-%d %H:%M:%S')"} echo "🚀 Push automatique sur la branche: $branch" @@ -35,7 +50,7 @@ auto_push() { # Ajouter tous les changements git add . - # Ne pas commiter si rien à commiter + # Ne pas commiter si rien à commite if [[ -z "$(git diff --cached --name-only)" ]]; then echo "ℹ️ Aucun changement indexé. Skip commit/push." return 0 @@ -54,7 +69,7 @@ auto_push() { # Fonction pour push avec message personnalisé push_with_message() { local message="$1" - local branch=${2:-$(git branch --show-current)} + local branch=${2:-$(get_current_branch)} echo "💬 Push avec message: $message" auto_push "$branch" "$message" @@ -62,7 +77,7 @@ push_with_message() { # Fonction pour push rapide (sans message) quick_push() { - local branch=${1:-$(git branch --show-current)} + local branch=${1:-$(get_current_branch)} auto_push "$branch" } @@ -149,4 +164,3 @@ case "$1" in esac echo "🎯 Push SSH automatique terminé !" -