diff --git a/scripts/scripts/auto-ssh-push.sh b/scripts/scripts/auto-ssh-push.sh index f635231..a813ec5 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" @@ -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" }