diff --git a/shell/up.sh b/shell/up.sh index 396aaf6..bdf4a4e 100755 --- a/shell/up.sh +++ b/shell/up.sh @@ -12,8 +12,12 @@ REPOS=( # Commit message COMMIT_MSG="auto up $(uptime)" +# Temporary file for logging statuses +TMP_LOG=$(mktemp) + process_repo() { local repo="$1" + local status="ok" if [ -d "$repo/.git" ]; then echo "Processing $repo..." @@ -22,12 +26,18 @@ process_repo() { git fetch git add . git commit -m "$COMMIT_MSG" >/dev/null 2>&1 || true - git pull --rebase - git push - echo "Done: $repo" + if ! git pull --rebase; then + status="conflict" + else + git push || status="push-failed" + fi + + echo "$repo:$status" >>"$TMP_LOG" + echo "Done: $repo ($status)" ) else echo "Skipping $repo: not a git repository" + echo "$repo:skipped" >>"$TMP_LOG" fi } @@ -37,3 +47,22 @@ done wait echo "All repositories processed." +echo + +# Summarize results +echo "=== Summary ===" +if grep -q "conflict" "$TMP_LOG"; then + grep "conflict" "$TMP_LOG" | while IFS=: read -r repo _; do + echo "⚠️ Conflict detected in: $repo" + done +else + echo "No conflicts detected." +fi + +if grep -q "push-failed" "$TMP_LOG"; then + grep "push-failed" "$TMP_LOG" | while IFS=: read -r repo _; do + echo "⚠️ Push failed for: $repo" + done +fi + +rm -f "$TMP_LOG"