Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Is there anyway to retrace on which branch a commit was made using the BitBucket API.

Nils Chapman
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
October 8, 2018

I am currently working on a small application that should print out commits of a project after a certain scheme. And for that i need to know on what branch a commit was made on.
Is there a way to do so using the Bitbucket API or isnt anything like that implemented in Git?.


Thx in advance for the Answers!

1 answer

1 accepted

0 votes
Answer accepted
aaddo
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 8, 2018

Hey Nils,

Welcome to the community! Thanks for your question.

The way Git it architectured, it is sometimes a difficult or inapplicable question to ask which branch a commit was made on. Git does not try to explicitly store this information.

One thing you could do is use the endpoint

/2.0/repositories/{username}/{repo_slug}/commits/{revision}

found over here to see which commits, starting from the tip of each specified branch, are reachable from that branch. If a commit exists around the tip of a certain branch and is not reachable anywhere else, the commit was likely made on that branch. However, you may find that older commits might exist on other calls to other branches, especially if some branches in your project have been merged.

Nils Chapman
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
October 9, 2018

 

I played around a bit with the Bitbucket gui and added these Parameters to the API call trough the URL : (?until=refs%2Fheads%2Frelease%2E2018.7.x&merges=include). I am unsure if it works this way but, I guess i doesn't if Bitbucket doesn't store Information like that. There is still the Question on what information do i get in the Response? If this dosent workout i will try the way u mentioned above.

What i forgot to mention is that i get a Response from the API with a bunch of Commits. But i am unsure if they were made on this specific branch or just a bunch of Commits mixed together.

 

If these question arent explained well enought just ask il try to explain them more clearly.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events