From bd6c5d445ac98e4d95fbd7296cc84b99b49107a7 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 17 Aug 2026 17:52:13 +0000 Subject: [PATCH] gitea-github-sync: fix set -e aborting do_sync on the first successful repo MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ((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 Claude-Session: https://claude.ai/code/session_01YEQNc4NfBST1m9NtCZVYa8 --- vendor/ai-stack/gitea-github-sync.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/vendor/ai-stack/gitea-github-sync.sh b/vendor/ai-stack/gitea-github-sync.sh index da9084f..2afd857 100755 --- a/vendor/ai-stack/gitea-github-sync.sh +++ b/vendor/ai-stack/gitea-github-sync.sh @@ -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