It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Is there a way via API to pull the commit history for a particular branch or tag?

I am trying to validate that fixes from one branch or release are merged forward. We tend to maintain a lot of version simultaneously. Online I found that in a git repo I can do something like 

git rev-list branch1 | grep $(git rev-parse branch2)

But we don't want to have to clone every repo either (we have a lot of those too).

Any ideas?

Thank you.

2 answers

Hi Chris,

There is a REST API that allows you to retrieve the commits for a particular branch:

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/commits?until={branch_name}

You can also limit how many commits to return by providing a since parameter specifying the earliest commit/ref to return. The REST API is paged for performance and scalability reasons, so you will have to make quite a few calls to retrieve the full commit history. It may be more efficient to write an add-on that works directly against the Java API instead. If that sounds like a reasonable option, I recommend starting with our developer documentation.

cheers,

Tim

Thank you so much for the pointer. I'd read about and played with the commits API but somehow missed that "until" took a ref as well as a SHA. I'd dismissed "since" and "until" as time-based and not that useful to my problem, but being able to pass a ref helps a lot more. I'm hoping that we'll mostly be looking at nearby branches and won't need to pull that much data since we at most need to go back to a common ancestor, but I'll keep the plugin approach in mind. 

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Bitbucket

Atlassian supported Jenkins integration for Bitbucket Server

We’ve been building a plugin to integrate Bitbucket Server and Jenkins CI, and I’m excited to announce that our alpha is ready to download and install. It lets you seamlessly configure a Jenkins job ...

1,091 views 3 17
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you