#!/usr/bin/env bash # Geht durch alle Git-Repos unter ~/projects/ und führt # pull, add, commit, push aus. Am Ende: Zusammenfassung. set -u PROJECTS_DIR="$HOME/projects" ok=() no_changes=() pull_failed=() push_failed=() no_upstream=() not_a_repo=() for dir in "$PROJECTS_DIR"/*/; do [ -d "$dir" ] || continue name="$(basename "$dir")" if [ ! -d "$dir/.git" ]; then not_a_repo+=("$name") continue fi echo "=== $name ===" cd "$dir" || continue if ! git pull --ff-only; then echo ">> Pull-Konflikt oder Fehler in '$name' – übersprungen" pull_failed+=("$name") continue fi git add -A if git diff --cached --quiet; then committed=false else git commit -m "update" committed=true fi if ! git rev-parse --abbrev-ref --symbolic-full-name '@{u}' >/dev/null 2>&1; then echo ">> Kein Upstream gesetzt für '$name'" no_upstream+=("$name") continue fi if git push; then if [ "$committed" = true ]; then ok+=("$name") else no_changes+=("$name") fi else echo ">> Push fehlgeschlagen für '$name'" push_failed+=("$name") fi done echo echo "==========================================" echo " Zusammenfassung" echo "==========================================" print_group() { local label="$1"; shift if [ "$#" -gt 0 ]; then echo "$label ($#):" printf ' - %s\n' "$@" fi } print_group "Erfolgreich gepusht" "${ok[@]:+${ok[@]}}" print_group "Keine Änderungen" "${no_changes[@]:+${no_changes[@]}}" print_group "Pull-Konflikt/Fehler" "${pull_failed[@]:+${pull_failed[@]}}" print_group "Push fehlgeschlagen" "${push_failed[@]:+${push_failed[@]}}" print_group "Kein Upstream" "${no_upstream[@]:+${no_upstream[@]}}" print_group "Kein Git-Repo" "${not_a_repo[@]:+${not_a_repo[@]}}"