Files
SuperSunday/push_patch.sh
2025-08-24 15:18:05 +00:00

51 lines
1.2 KiB
Bash
Executable File
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env bash
set -euo pipefail
MSG="${1:-🚀 Patch auto}"
SCRIPT_NAME="$(basename "$0")"
# 0) pré-checks
git rev-parse --is-inside-work-tree >/dev/null 2>&1 || {
echo "❌ Lance ce script depuis la racine d'un dépôt git."; exit 1; }
# 1) se placer/Créer la branche main
if git show-ref --verify --quiet refs/heads/main; then
git checkout main
else
git checkout -b main
fi
# 2) vérifier remote
git remote get-url origin >/dev/null 2>&1 || {
echo "❌ Pas de remote 'origin'. Fais: git remote add origin <URL>"; exit 1; }
# 3) forcer lajout du script même sil est ignoré
if git check-ignore -q "$SCRIPT_NAME"; then
echo " $SCRIPT_NAME est ignoré par .gitignore → ajout forcé"
git add -f "$SCRIPT_NAME"
else
git add "$SCRIPT_NAME"
fi
# 4) ajouter tout le reste sauf les fichiers indésirables
git add . \
':!*.DS_Store' \
':!*.AppleDouble' \
':!*.LSOverride'
# 5) commit si nécessaire
if git diff --cached --quiet; then
echo " Rien à commit."
else
git commit -m "$MSG"
echo "✅ Commit créé: $MSG"
fi
# 6) push
if git rev-parse --abbrev-ref main@{u} >/dev/null 2>&1; then
git push origin main
else
git push -u origin main
fi
echo "✅ Push terminé sur 'origin/main'."