fix: disinto init: race condition in post-push empty check (#773)
Replace the single-shot Forgejo API emptiness check in push_to_forge() with a retry loop (up to 5 attempts, 2s apart). Forgejo needs a brief delay to index pushed refs, so the immediate check could see stale metadata reporting empty=true even though the push succeeded. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
c62bdfdf5b
commit
220b5c4004
1 changed files with 22 additions and 12 deletions
34
bin/disinto
34
bin/disinto
|
|
@ -861,19 +861,29 @@ push_to_forge() {
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Verify the repo is no longer empty
|
# Verify the repo is no longer empty (Forgejo may need a moment to index pushed refs)
|
||||||
local repo_info
|
local is_empty="true"
|
||||||
repo_info=$(curl -sf --max-time 10 \
|
local verify_attempt
|
||||||
-H "Authorization: token ${FORGE_TOKEN}" \
|
for verify_attempt in $(seq 1 5); do
|
||||||
"${forge_url}/api/v1/repos/${repo_slug}" 2>/dev/null) || repo_info=""
|
local repo_info
|
||||||
if [ -n "$repo_info" ]; then
|
repo_info=$(curl -sf --max-time 10 \
|
||||||
local is_empty
|
-H "Authorization: token ${FORGE_TOKEN}" \
|
||||||
is_empty=$(printf '%s' "$repo_info" | jq -r '.empty // "unknown"')
|
"${forge_url}/api/v1/repos/${repo_slug}" 2>/dev/null) || repo_info=""
|
||||||
if [ "$is_empty" = "true" ]; then
|
if [ -z "$repo_info" ]; then
|
||||||
echo "Warning: Forgejo repo still reports empty after push" >&2
|
break # API unreachable, skip verification
|
||||||
return 1
|
|
||||||
fi
|
fi
|
||||||
echo "Verify: repo is not empty (push confirmed)"
|
is_empty=$(printf '%s' "$repo_info" | jq -r '.empty // "unknown"')
|
||||||
|
if [ "$is_empty" != "true" ]; then
|
||||||
|
echo "Verify: repo is not empty (push confirmed)"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
if [ "$verify_attempt" -lt 5 ]; then
|
||||||
|
sleep 2
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
if [ "$is_empty" = "true" ]; then
|
||||||
|
echo "Warning: Forgejo repo still reports empty after push" >&2
|
||||||
|
return 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue