How to determine if a PR can be merged?

Hi folks,
I am looking for a programmatic possibility to determine via v3 API if a PR can be merged, i.e., actually the boolean status that makes the “merge” button green or red.

For instance, PullRequest mergeable_state possible values goes in a similar direction. “mergeable” only let’s me know if the PR has no potential merge conflicts. But all the other criteria like reviews, statuses, etc. would need to be queried individually.

In v4 MergeStateStatus seems to be what I am looking for. But can I also achieve the same by v3 means?


:wave: hello there and welcome to the GitHub Support Community, @xtough !

I recently answered a similar question here. I’m wondering if that helps with what you’re looking for? :thought_balloon:

Thanks francisfuzz. Yes, this sort of helps. mergeable_state==“BLOCKED” is indeed what I was looking for. I was just confused because it is not part of the documented API. I guess the chances are small that the possible values will change incompatibly, no that the v4 API is more or less cementing the same.

1 Like