2.6 KiB
2.6 KiB
name, description
| name | description |
|---|---|
| gitea-pr-api-cycle | Open/update/merge PRs and issues on the Dankclaw Gitea API (192.168.0.143:3000, dank/command-center) with the token-safe curl+jq sequence, including the {"Do":"merge"} merge payload and post-merge live-checkout fast-forward. |
Gitea PR/issue cycle — dank/command-center
Friction-earned 2026-10-18 across PRs #15–#20 and issue #18: three separate fumbles (jq trailer flag, 422 merge payload, silent -o/-w swallowing) codified once.
Where
- API base:
http://192.168.0.143:3000/api/v1/repos/dank/command-center/{pulls,issues} - Token: never inline, never echoed. Extract from the git credential file into a 600-perm temp curl config:
tok=$(sed -nE 's#^http://[^:/@]+:([^@]+)@192\.168\.0\.143.*#\1#p' ~/.config/secrets/gitea | head -1)cfg=$(mktemp); chmod 600 "$cfg"; printf 'header = "Authorization: token %s"\n' "$tok" > "$cfg"→curl -K "$cfg";rm -f "$cfg"when done. - Unauthenticated GET works for state reads (
GET /pulls/N→jq -c '{state,merged,merge_commit_sha}').
Body construction (the two traps)
- Build JSON with
jq -n --arg t <title> --arg b "$(cat b.txt)" '{title:$t, head:<branch>, base:"main", body:$b}'; write the body to a temp file first (printf '%s' … > b.txt). NEVER pass---as a bare jq argument — jq parses it as a flag (unknown flag: ---). The AGENTS.md attribution trailer (---+cwd: … · session: …) goes INSIDE the body string. - Always capture status explicitly:
-o r.json -w '%{http_code}'and print it; a bare-ohides failures (a 422 looked like success-with-no-output once).
Merge (the 422 trap)
POST /pulls/N/merge requires body {"Do":"merge"} — Do is the Required field on this Gitea. {}, {"DoNotMerge":false}, {"merge_style":…} all return 422 ("[Do]: Required"). Success may return an EMPTY body — verify by GET afterwards (state=closed, merged=true), not by the POST response.
- Merge only with Frank's explicit per-PR OK (repo law).
- Post-merge the live deployment must follow:
git -C ~/.omp fetch -q origin && git -C ~/.omp merge --ff-only origin/main(the checkout IS the deployment; branch ismain).
PR etiquette per AGENTS.md
- Immediately after opening:
xdg-open <PR-URL>lands it in Frank's Firefox. - Redesign mid-review: amend +
git push -fthe branch, then PATCH the PR body (/pulls/N,{"body":…}) so title/body match the net diff — verify{number,state,mergeable}in the response. - Issue creation identical shape:
POST /issueswith{title, body}, expect 201; PATCH same endpoint/issues/Nto fix bodies retroactively, then GET-readback verify.