gitea-github-sync: fix set -e aborting do_sync on the first successful repo

((pull_count++)) evaluates to the PRE-increment value — 0 on the very
first successful pull/push — and under this script's `set -euo pipefail`,
an arithmetic command evaluating to 0 counts as a failing command and
kills the script immediately. Confirmed live: a real, fully successful
GitHub -> Gitea pull (visible in sync.log as "PULL ... OK") still made
the whole run exit non-zero and get reported as "Sync run failed", purely
because it was the first repo to sync (0 -> 1). Any subsequent repo in
the same run would have been fine, but most real installs only have a
handful of repos, so this could look like sync is just broken.

Switched all three counters (pull_count, push_count, fail_count) to
assignment form (`count=$((count + 1))`), which always exits 0 regardless
of the resulting value. page++ elsewhere in the file starts at 1, not 0,
so it isn't affected by this and was left as-is.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YEQNc4NfBST1m9NtCZVYa8
This commit is contained in:
Claude
2026-08-17 17:52:13 +00:00
parent eae02da074
commit bd6c5d445a
+4 -4
View File
@@ -381,9 +381,9 @@ do_sync() {
[[ -n "$SINGLE_REPO" && "$name" != "$SINGLE_REPO" ]] && continue
is_excluded "$name" && continue
if sync_github_to_gitea "$name" "$url" "$priv"; then
((pull_count++))
pull_count=$((pull_count + 1))
else
((fail_count++))
fail_count=$((fail_count + 1))
fi
done < <(get_github_repos)
fi
@@ -402,9 +402,9 @@ do_sync() {
continue
fi
if sync_gitea_to_github "$name" "$url" "$priv"; then
((push_count++))
push_count=$((push_count + 1))
else
((fail_count++))
fail_count=$((fail_count + 1))
fi
done < <(get_gitea_repos)
fi