Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Is it possible to get a list of commits on a branch using the BitBucket API?

jabendroth2 November 29, 2017

I'm trying to get a list of commits for a specific branch.  I've tried the following:

https://api.bitbucket.org/2.0/repositories/<username>/<repo>/commits/<branch>

And:

https://api.bitbucket.org/2.0/repositories/<username>/<repo>/commits?include=<branch>

Neither one works.  With the first URL, the commit list that's returned starts at the latest commit in the branch.  However, the list includes other commits that aren't related to that branch in any way.

I know it's doing something when I specify the branch because if I specify a branch name that doesn't exist, I get an error.  What I'm ultimately trying to do is determine if a branch is a child of another branch, but there doesn't seem to be a way to do this with the current API.

1 answer

1 vote
jabendroth2 November 30, 2017

I figured it out after reading through the docs some more - I used the following sequence:

  1. Get the refs object for the branch in question.  i.e. https://api.bitbucket.org/2.0/repositories/<username>/<repo>/refs?q=name=%22<branch>%22
  2. Walk the target.parent objects and get the statuses object for each one until the refname is not equal to the branch name.
kesavamoorthy December 10, 2018

Hi 

Can you please little elaborate how this is implemented?

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events