2026-03-16 21:22:53 +01:00
|
|
|
#!/usr/bin/env bash
|
2026-03-21 19:59:55 +00:00
|
|
|
set -euo pipefail
|
2026-03-16 21:22:53 +01:00
|
|
|
# parse-deps.sh — Extract dependency issue numbers from an issue body
|
|
|
|
|
#
|
|
|
|
|
# Usage:
|
|
|
|
|
# echo "$ISSUE_BODY" | bash lib/parse-deps.sh
|
|
|
|
|
#
|
|
|
|
|
# Output: one dep number per line, sorted and deduplicated
|
|
|
|
|
#
|
|
|
|
|
# Matches:
|
|
|
|
|
# - Sections: ## Dependencies / ## Depends on / ## Blocked by
|
|
|
|
|
# - Inline: "depends on #NNN" / "blocked by #NNN" anywhere
|
|
|
|
|
# - Ignores: ## Related (safe for sibling cross-references)
|
|
|
|
|
|
|
|
|
|
BODY=$(cat)
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
# Extract #NNN from dependency sections
|
|
|
|
|
echo "$BODY" | awk '
|
|
|
|
|
BEGIN { IGNORECASE=1 }
|
|
|
|
|
/^##? *(Depends on|Blocked by|Dependencies)/ { capture=1; next }
|
|
|
|
|
capture && /^##? / { capture=0 }
|
|
|
|
|
capture { print }
|
|
|
|
|
' | grep -oP '#\K[0-9]+' || true
|
|
|
|
|
|
2026-03-23 02:25:21 +00:00
|
|
|
# Also check inline deps on same line as keyword (skip fenced code blocks)
|
|
|
|
|
echo "$BODY" | awk '
|
2026-03-23 10:59:47 +00:00
|
|
|
BEGIN { IGNORECASE=1 }
|
2026-03-23 02:26:49 +00:00
|
|
|
/^```/ { incode = !incode; next }
|
|
|
|
|
incode { next }
|
2026-03-23 10:59:47 +00:00
|
|
|
/blocked by|depends on/ { print }
|
2026-03-23 02:25:21 +00:00
|
|
|
' | grep -oP '#\K[0-9]+' || true
|
2026-03-16 21:22:53 +01:00
|
|
|
} | sort -un
|