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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,551,714
Community Members
 
Community Events
184
Community Groups

How to see which branch a commit was made on when grabbing commits and branches from the cloud api?

Mir Aman
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!
May 03, 2023

https://api.bitbucket.org/2.0/repositories/{workspace}/{repo_slug}/commits

 

I am using the above endpoint to pull all commits from all projects and I want to be able to link commits to the branch it was made on. But I dont see any reference to the branch, under "parents" object, there is only reference to the parent commit. 

Does anyone know where I can find this relationship? 

 

1 answer

1 accepted

1 vote
Answer accepted
Patrik S
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 04, 2023

Hello @Mir Aman ,

Welcome to the Community!

While the List commits endpoint doesn't directly return the branches that the commit is part of, we do have a feature request opened to implement the ability to get the branches that contains a commit : 

Feel free to add your vote there and mark yourself as a watcher to receive first-hand updates on the implementation of that feature.

A workaround I can think of is to provide the branch name in the List commits endpoint so it will just return the commits for that specific branch, like in the below example : 

https://api.bitbucket.org/2.0/repositories/<workspace>/<repository>/commits/<branch name>

You could first get the List of branches and then for each branch returned, call the endpoint above to get all the commits contained in that particular branch.

Hope that helps!

Let me know in case you have any questions.

Thank you, @Mir Aman !

Patrik S

Mir Aman
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!
May 10, 2023

I just want to add incase anyone else needs this for future reference, the method suggested by Patrik works, but there is a lot of redundant data, as commits made on the parent branches are included in the child branch. This requires some cleanup after getting the response but otherwise is a good solution.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
TAGS
AUG Leaders

Atlassian Community Events