Merge pull request 'fix: fix: create_labels creates duplicate labels on re-run — no idempotency check (#683)' (#698) from fix/issue-683 into main
This commit is contained in:
commit
ba1ab6e653
1 changed files with 13 additions and 1 deletions
14
bin/disinto
14
bin/disinto
|
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue