fix: fix: create_labels creates duplicate labels on re-run — no idempotency check (#683)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
openhands 2026-03-25 15:35:31 +00:00
parent ec658e3c52
commit 54ce91e09e

View file

@ -865,8 +865,20 @@ create_labels() {
) )
echo "Creating labels on ${repo}..." echo "Creating labels on ${repo}..."
# Fetch existing labels so we can skip duplicates
local existing
existing=$(curl -sf \
-H "Authorization: token ${FORGE_TOKEN}" \
"${api}/labels?limit=50" 2>/dev/null \
| grep -o '"name":"[^"]*"' | cut -d'"' -f4) || existing=""
local name color local name color
for name in backlog in-progress blocked tech-debt underspecified vision action; do for name in backlog in-progress blocked tech-debt underspecified vision action; do
if echo "$existing" | grep -qx "$name"; then
echo " . ${name} (already exists)"
continue
fi
color="${labels[$name]}" color="${labels[$name]}"
if curl -sf -X POST \ if curl -sf -X POST \
-H "Authorization: token ${FORGE_TOKEN}" \ -H "Authorization: token ${FORGE_TOKEN}" \
@ -875,7 +887,7 @@ create_labels() {
-d "{\"name\":\"${name}\",\"color\":\"${color}\"}" >/dev/null 2>&1; then -d "{\"name\":\"${name}\",\"color\":\"${color}\"}" >/dev/null 2>&1; then
echo " + ${name}" echo " + ${name}"
else else
echo " . ${name} (already exists)" echo " ! ${name} (failed to create)"
fi fi
done done
} }