Files
TVGuide/gitpush.sh
T
2026-07-07 09:07:59 +02:00

91 lines
2.0 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
if [ $# -lt 1 ]; then
echo
echo "Verwendung:"
echo " ./gitpush.sh \"Commit-Kommentar\""
echo
exit 1
fi
COMMENT="$*"
cd "$(dirname "$0")"
echo
echo "======================================================"
echo " TVGuide Git Helper"
echo "======================================================"
BRANCH=$(git branch --show-current)
CHANGED=$(git status --short | wc -l)
echo "Branch : $BRANCH"
echo "Änderungen: $CHANGED Datei(en)"
echo "Kommentar : $COMMENT"
echo
echo "------------------------------------------------------"
echo "PHP Syntax Check"
echo "------------------------------------------------------"
find app -name "*.php" -print0 | while IFS= read -r -d '' file; do
php -l "$file" > /dev/null
echo "✓ $file"
done
echo
if [ "$CHANGED" -eq 0 ]; then
echo "Keine Änderungen vorhanden."
echo
exit 0
fi
echo "------------------------------------------------------"
echo "Git Status"
echo "------------------------------------------------------"
git status --short
echo
echo "------------------------------------------------------"
echo "git add ."
echo "------------------------------------------------------"
git add .
echo
echo "------------------------------------------------------"
echo "git commit"
echo "------------------------------------------------------"
if git diff --cached --quiet; then
echo "Keine Änderungen zum Commit vorhanden."
exit 0
fi
git commit -m "$COMMENT"
echo
echo "------------------------------------------------------"
echo "git push"
echo "------------------------------------------------------"
git push
HASH=$(git rev-parse --short HEAD)
echo
echo "======================================================"
echo "✓ Erfolgreich abgeschlossen"
echo
echo "Branch : $BRANCH"
echo "Commit : $HASH"
echo "Text : $COMMENT"
echo "Zeit : $(date '+%Y-%m-%d %H:%M:%S')"
echo "======================================================"
echo