hi,
I'm trying to find out if a commit is within a branch. I thought I could filter the commits in a branch eg
https://api.bitbucket.org/2.0/repositories/cartoncloud/service-access/commits/staging
returns a response with the "hash" that I thought I could filter on.
values: [ { "rendered": { .. }, "hash": "fed8b7a890fb2dafb7eb7d44bd11d2e7efb36fa3", ...
So based on sort and filter doc I should be able to do this.
https://api.bitbucket.org/2.0/repositories/cartoncloud/service-access/commits/staging?q=hash=fed8b7a890fb2dafb7eb7d44bd11d2e7efb36fa3
However this gives exactly the same response ie seems filter not applied.
Also tried
https://api.bitbucket.org/2.0/repositories/cartoncloud/service-access/commits/?hash=fed8b7a890fb2dafb7eb7d44bd11d2e7efb36fa3&include=staging
without success.
Seems the only approach is to page through all commits for a branch and search within each page response for that commit?
Thanks.
@izalcomax The commits API is a little bit special and not filterable using `q=`. That said there are a few handy URL params for include/excluding commits.
Compare these
https://api.bitbucket.org/2.0/repositories/atlassian/bbql/commits/master?fields=values.hash,values.message
https://api.bitbucket.org/2.0/repositories/atlassian/bbql/commits/master?fields=values.hash,values.message&include=a225c3e87f897167550469144cdff0631f3995d0
If you enter a commit has that's not reachable on that branch then you get a message like:
{ "data": { "shas": [ "a225c3e87f897167550469144cdff0631f3995d1" ] }, "type": "error", "error": { "message": "Commit not found", "data": { "shas": [ "a225c3e87f897167550469144cdff0631f3995d1" ] } }}
See more examples here: https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Bworkspace%7D/%7Brepo_slug%7D/commits
It looks like you're new here. Sign in or register to get started.