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?
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
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.