Git helper with PHP syntax check

This commit is contained in:
Gogs
2026-07-07 09:07:59 +02:00
parent ffa002fc27
commit 888867e118
+63 -10
View File
@@ -1,9 +1,12 @@
#!/bin/bash
#!/usr/bin/env bash
set -e
set -euo pipefail
if [ $# -eq 0 ]; then
echo "Verwendung: $0 \"Commit-Kommentar\""
if [ $# -lt 1 ]; then
echo
echo "Verwendung:"
echo " ./gitpush.sh \"Commit-Kommentar\""
echo
exit 1
fi
@@ -11,17 +14,54 @@ COMMENT="$*"
cd "$(dirname "$0")"
echo ">>> Git Status"
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 ">>> git add ."
echo "------------------------------------------------------"
echo "git add ."
echo "------------------------------------------------------"
git add .
echo
echo ">>> git commit -m \"$COMMENT\""
echo "------------------------------------------------------"
echo "git commit"
echo "------------------------------------------------------"
# Nur committen, wenn es Änderungen gibt
if git diff --cached --quiet; then
echo "Keine Änderungen zum Commit vorhanden."
exit 0
@@ -30,8 +70,21 @@ fi
git commit -m "$COMMENT"
echo
echo ">>> git push"
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
echo "✅ Fertig."