fix: use .[][].name in jq for wrapped JSON response

API returns { "resources": [...] } not bare arrays, so .[].name
produced no output. Use .[][].name to unwrap the outer object first.
Also auto-load .env in pr.sh.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Michal
2026-02-23 19:26:47 +00:00
parent 8d296b6b7c
commit 0a641491a4
4 changed files with 28 additions and 16 deletions

17
pr.sh
View File

@@ -1,11 +1,18 @@
#!/usr/bin/env bash
# Usage: source .env && bash pr.sh "PR title" "PR body"
# Requires GITEA_TOKEN in environment
# Usage: bash pr.sh "PR title" "PR body"
# Loads GITEA_TOKEN from .env automatically
set -euo pipefail
GITEA_URL="http://10.0.0.194:3012"
REPO="michal/mcpctl"
# Load .env if GITEA_TOKEN not already exported
if [ -z "${GITEA_TOKEN:-}" ] && [ -f .env ]; then
set -a
source .env
set +a
fi
GITEA_URL="${GITEA_URL:-http://10.0.0.194:3012}"
REPO="${GITEA_OWNER:-michal}/mcpctl"
TITLE="${1:?Usage: pr.sh <title> [body]}"
BODY="${2:-}"
@@ -18,7 +25,7 @@ if [ "$HEAD" = "$BASE" ]; then
fi
if [ -z "${GITEA_TOKEN:-}" ]; then
echo "Error: GITEA_TOKEN not set. Run: source .env" >&2
echo "Error: GITEA_TOKEN not set and .env not found" >&2
exit 1
fi