How to check mergeability of a branches using the

2020-08-10 09:23发布

问题:

I'm trying to check if branch can be merged to another using the github API. There is a property mergeable in GET /repos/:owner/:repo/pulls/:number, but I don't actually want to create a pull request before I know that branches can be merged w/o conflicts.

On the github website, when creating a pull request, there is a call to this address which doesn't seem to be an API method (it returns HTML saying whether branches can be merged or not). But still I could use this call, the problem is I have no clue what '1373893022922' refers to. I'd suggest it's somehow connected to the base branch (newdev3 is head).

Any ideas?

回答1:

There's now a mergeable property in the PR response.



回答2:

There's no easy way (it seems) to do this. Your best bet is to attempt to merge the two branches using the Merging API but that would result in a merge if in fact the two branches are mergeable. I suspect that's not what you're looking for.

You could also clone the repository and just those two branches and refer to some other questions here on StackOverflow that address whether two branches are fast-forwardable. That may be a more reliable way of determining this.