Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check mergeability of a branches using the github api

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?

like image 326
shaap_the_great Avatar asked Jul 15 '13 13:07

shaap_the_great


2 Answers

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

like image 168
drewish Avatar answered Sep 20 '22 16:09

drewish


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.

like image 35
Ian Stapleton Cordasco Avatar answered Sep 23 '22 16:09

Ian Stapleton Cordasco