Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions scripts/super-board-card.sh
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,18 @@ items() { # whole board, gh item-list shape, ~1 point per 100 cards
|| { echo "board read incomplete" >&2; return 69; }
}

# The reads above run strict, so anything GitHub rejects halts the whole run.
# A malformed issue is the caller's mistake, not GitHub's: refuse it here (64).
# zsh does not word-split `set -- $pair`, which once passed "26 53" as one issue.
issue_arg() { # $1 = issue
[[ "$1" =~ ^[1-9][0-9]*$ ]] && return 0
echo "invalid issue: '$1' — pass one issue number per call" >&2; exit 64
}

case "$VERB" in
move) [ $# -eq 2 ] || { echo "usage: move <issue> <Status>" >&2; exit 64; }; move "$1" "$2" ;;
status) [ $# -eq 1 ] || { echo "usage: status <issue>" >&2; exit 64; }; read_card "$1"; echo "$STATUS_NAME" ;;
item-id) [ $# -eq 1 ] || { echo "usage: item-id <issue>" >&2; exit 64; }; item_id "$1"; echo "$ITEM_ID" ;;
move) [ $# -eq 2 ] || { echo "usage: move <issue> <Status>" >&2; exit 64; }; issue_arg "$1"; move "$1" "$2" ;;
status) [ $# -eq 1 ] || { echo "usage: status <issue>" >&2; exit 64; }; issue_arg "$1"; read_card "$1"; echo "$STATUS_NAME" ;;
item-id) [ $# -eq 1 ] || { echo "usage: item-id <issue>" >&2; exit 64; }; issue_arg "$1"; item_id "$1"; echo "$ITEM_ID" ;;
ids) load_ids; jq -n --arg p "$PROJECT_ID" --arg f "$FIELD_ID" --argjson o "$OPTIONS_JSON" '{projectId:$p, fieldId:$f, options:$o}' ;;
items) items ;;
*) echo "unknown verb: $VERB" >&2; exit 64 ;;
Expand Down
15 changes: 15 additions & 0 deletions tests/test-card.sh
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,19 @@ RC=0; card items >/dev/null 2>&1 || RC=$?
[ "$RC" != 0 ] || fail "incomplete board read must fail"
ok "incomplete board read refused"

# 10 — a card number that is not one positive integer is a usage error (64):
# no GitHub call, no halt file. zsh does not word-split `$pair`, so
# `set -- $pair` once passed "26 53" here and halted a whole run (3 retries).
for bad in "26 53" "#26" "abc" "0" ""; do
for verb in status item-id; do
reset_log; rm -f "$TMP/halt.json"; RC=0; card $verb "$bad" >/dev/null 2>&1 || RC=$?
[ "$RC" = 64 ] || fail "$verb '$bad' should exit 64 (rc=$RC)"
[ ! -s "$FAKE_LOG" ] || fail "$verb '$bad' must not call gh: $(cat "$FAKE_LOG")"
[ ! -e "$TMP/halt.json" ] || fail "$verb '$bad' must not write a halt file"
done
reset_log; RC=0; card move "$bad" QA >/dev/null 2>&1 || RC=$?
[ "$RC" = 64 ] && [ ! -s "$FAKE_LOG" ] || fail "move '$bad' should exit 64 with no gh call (rc=$RC)"
done
ok "bad card number → 64, no GitHub call, no halt"

echo "PASS: $pass card-helper checks"