fix(push): compat git sans show-current (fallback branche)
This commit is contained in:
parent
99e1e0bda7
commit
46d5d20c7d
@ -26,8 +26,23 @@ fi
|
|||||||
echo "✅ Authentification SSH réussie"
|
echo "✅ Authentification SSH réussie"
|
||||||
|
|
||||||
# Fonction pour push automatique
|
# 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() {
|
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')"}
|
local commit_message=${2:-"Auto-commit $(date '+%Y-%m-%d %H:%M:%S')"}
|
||||||
|
|
||||||
echo "🚀 Push automatique sur la branche: $branch"
|
echo "🚀 Push automatique sur la branche: $branch"
|
||||||
@ -54,7 +69,7 @@ auto_push() {
|
|||||||
# Fonction pour push avec message personnalisé
|
# Fonction pour push avec message personnalisé
|
||||||
push_with_message() {
|
push_with_message() {
|
||||||
local message="$1"
|
local message="$1"
|
||||||
local branch=${2:-$(git branch --show-current)}
|
local branch=${2:-$(get_current_branch)}
|
||||||
|
|
||||||
echo "💬 Push avec message: $message"
|
echo "💬 Push avec message: $message"
|
||||||
auto_push "$branch" "$message"
|
auto_push "$branch" "$message"
|
||||||
@ -62,7 +77,7 @@ push_with_message() {
|
|||||||
|
|
||||||
# Fonction pour push rapide (sans message)
|
# Fonction pour push rapide (sans message)
|
||||||
quick_push() {
|
quick_push() {
|
||||||
local branch=${1:-$(git branch --show-current)}
|
local branch=${1:-$(get_current_branch)}
|
||||||
auto_push "$branch"
|
auto_push "$branch"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user