Merge pull request 'fix: disinto init: race condition in post-push empty check (#773)' (#776) from fix/issue-773 into main
This commit is contained in:
commit
e0f977be20
2 changed files with 33 additions and 18 deletions
|
|
@ -21,9 +21,12 @@ FAILED=0
|
||||||
# Uses awk instead of grep -Eo for busybox/Alpine compatibility (#296).
|
# Uses awk instead of grep -Eo for busybox/Alpine compatibility (#296).
|
||||||
get_fns() {
|
get_fns() {
|
||||||
local f="$1"
|
local f="$1"
|
||||||
awk '/^[ \t]*[a-zA-Z_][a-zA-Z0-9_]+[ \t]*\(\)/ {
|
# Use POSIX character classes and bracket-escaped parens for BusyBox awk
|
||||||
sub(/^[ \t]+/, "")
|
# compatibility (BusyBox awk does not expand \t to tab in character classes
|
||||||
sub(/[ \t]*\(\).*/, "")
|
# and may handle \( differently in ERE patterns).
|
||||||
|
awk '/^[[:space:]]*[a-zA-Z_][a-zA-Z0-9_]+[[:space:]]*[(][)]/ {
|
||||||
|
sub(/^[[:space:]]+/, "")
|
||||||
|
sub(/[[:space:]]*[(][)].*/, "")
|
||||||
print
|
print
|
||||||
}' "$f" 2>/dev/null | sort -u || true
|
}' "$f" 2>/dev/null | sort -u || true
|
||||||
}
|
}
|
||||||
|
|
@ -64,9 +67,10 @@ get_candidates() {
|
||||||
if (match(p, /^[a-z][a-zA-Z0-9_]*_[a-zA-Z0-9_]+/)) {
|
if (match(p, /^[a-z][a-zA-Z0-9_]*_[a-zA-Z0-9_]+/)) {
|
||||||
word = substr(p, RSTART, RLENGTH)
|
word = substr(p, RSTART, RLENGTH)
|
||||||
rest = substr(p, RSTART + RLENGTH, 1)
|
rest = substr(p, RSTART + RLENGTH, 1)
|
||||||
# Skip: case labels (word) or word|), Python/jq patterns (word:),
|
# Skip: function definitions (word(), case labels (word) or word|),
|
||||||
# object method calls (word.method), assignments (word=)
|
# Python/jq patterns (word:), object method calls (word.method),
|
||||||
if (rest == ")" || rest == "|" || rest == ":" || rest == "." || rest == "=") continue
|
# assignments (word=)
|
||||||
|
if (rest == "(" || rest == ")" || rest == "|" || rest == ":" || rest == "." || rest == "=") continue
|
||||||
print word
|
print word
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
35
bin/disinto
35
bin/disinto
|
|
@ -861,19 +861,30 @@ 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
|
is_empty="skipped"
|
||||||
return 1
|
break # API unreachable, skip verification
|
||||||
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