E.g. in this PR the button is not added although the branch is out-of date. The feature bails out directly because I can't merge the PR (it's a fork of a repo I don't have access to):
https://github.com/sindresorhus/refined-github/blob/7589633720493550e359468ffdb4294858b74646/source/features/update-pr-from-base-branch.tsx#L97-L105
I can successfully call the update-branch API endpoint though. I tested that in a similar PR by commenting out the lines above and clicking the button.
Because the logic when to add / don't add the button seems quite complicated and has changed quite a bit in the past (9022674, 4b3fff7, 45e4323, 5787ed7, c5ab9a9, 15600fe), I haven't really tried to solve it myself.
These are the rules I worked out myself (please add more I forgot!):
- If you can't edit the PR (because you opened it or have repo access), bail out ❌
- If the branch is not out-of-date, bail out. ❌
- If the head is
unknown repository, bail out ❌
- If the repo enabled the
Require branches to be up to date before merging branch setting, there is already an "Update branch" button. ❌
- If the branch has merge conflicts and the PR is not a draft, there is already a "Resolve conflicts" button. ❌
- In all other cases, add the button. ✔️
E.g. in this PR the button is not added although the branch is out-of date. The feature bails out directly because I can't merge the PR (it's a fork of a repo I don't have access to):
https://github.com/sindresorhus/refined-github/blob/7589633720493550e359468ffdb4294858b74646/source/features/update-pr-from-base-branch.tsx#L97-L105
I can successfully call the
update-branchAPI endpoint though. I tested that in a similar PR by commenting out the lines above and clicking the button.Because the logic when to add / don't add the button seems quite complicated and has changed quite a bit in the past (9022674, 4b3fff7, 45e4323, 5787ed7, c5ab9a9, 15600fe), I haven't really tried to solve it myself.
These are the rules I worked out myself (please add more I forgot!):
unknown repository, bail out ❌Require branches to be up to date before mergingbranch setting, there is already an "Update branch" button. ❌