fix(release): fetch file SHAs from base branch, not next-release #24
Reference in New Issue
Block a user
Delete Branch "fix-release-fetch-sha-from-base"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Why
After #23, the workflow on
robotframeworkfailed withCHANGELOG.md write failed after 5 attempts (422): {"message":"repository file already exists [path: CHANGELOG.md]"}.Sequence from the log:
POST /branches→ 201 (branch created).GET /branches/next-release→ 500, 500, then 200 (the readiness poll worked).fetch_shathen queriedGET /contents/CHANGELOG.md?ref=next-releaseimmediately after — that endpoint was still propagating and didn't return the SHA, sofetch_shacame back empty.write_filesaw no SHA, used POST (create), and got HTTP 422 because the file genuinely existed on base (and therefore on the freshly forkednext-release).Different Gitea API endpoints don't share a single readiness signal for a newly created branch —
/branchescan report ready while/contentsis still 500/404.Changes
fetch_shanow queries?ref=${BASE_BRANCH}instead of?ref=next-release. Base is stable, and Gitea content writes are content-addressed by blob SHA, so a SHA fetched from main works for PUT onnext-release(it was just forked from main, so the blob is identical).Test plan
robotframework(or another repo with an existing CHANGELOG.md on main). Confirm CHANGELOG.md and .version both write via PUT first try, and PR is created.fetch_shareturns empty after 404,write_filePOSTs to create — confirm this path still works.After POST /branches reports 201 and GET /branches/next-release reports 200, the /contents/{path}?ref=next-release endpoint can still 500 or 404 transiently while Gitea finishes indexing the new branch. That caused fetch_sha to return empty for files that actually existed on base, so write_file fell back to POST (create) and got HTTP 422 "repository file already exists" five times before giving up. Query base branch for the blob SHA instead. Base is stable, and Gitea content writes are content-addressed by blob SHA, so a SHA fetched from main works for PUT on next-release (next-release was just forked from main, so the blob is identical). Treat 404 as "file absent" and retry other non-200 responses up to 5 times.