You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(github): reuse an existing repo-docs branch ref instead of failing (#8310) (#8481)
openRepoDocPullRequest always targets the fixed loopover/repo-docs branch, but
only looks for an OPEN pull request on it before deciding to create the ref. A
maintainer who closes the repo-doc PR without deleting its branch (GitHub never
forces that, and an API/bot close deletes nothing) leaves the ref behind: the
open-only lookup finds nothing, POST /git/refs then 422s "Reference already
exists", and the outer catch turns every later refresh into
{ opened: false }, permanently.
When the create reports that specific failure, fall back to
PATCH /git/refs/{ref} with { sha, force: true } and continue into the existing
PR-open path unchanged. The branch is owned solely by this feature (per the
file's own header comment), never shared with contributor work, so force-
updating it to the freshly built commit is safe.
Deliberately narrow:
- Only a 422 whose message says "Reference already exists" recovers; any other
create-ref failure still propagates to the outer catch's fail-safe, so a bad
sha is never force-pushed over.
- The "reuse only an OPEN PR" behaviour is untouched -- a closed PR still
results in a NEW pull request, only the underlying ref is reused.
- Reuses the existing githubErrorStatus and errorMessage helpers rather than
hand-rolling status/message extraction.
Adds two tests: the 422 path force-updates the ref and still opens a fresh PR
(reused: false), and an unrelated create-ref 422 issues no PATCH and degrades
to opened: false.
0 commit comments