atlassian-api / atlassian-python-api

Atlassian Python REST API wrapper
https://atlassian-python-api.readthedocs.io
Apache License 2.0
1.29k stars 643 forks source link

[Bitbucket Cloud] query parameter not supported on commits.each() #1249

Open niharmkn opened 9 months ago

niharmkn commented 9 months ago

Hi,

I'm trying to use the q parameter to filter the list of commits that commits.each() generates but that doesn't seem to work:

commits = repository.commits.each(q="hash=\"7d947c8a7c70bc72d8e77f0d1010a380ccf7c03f\"") for commit in commits: print(f'Commit: \n {commit.data["hash"]}\n')

it gives me all of the commits hash in my repository. Did someone experience something similar? On the Atlassian docs, it is not clarified if the pipelines endpoint supports query filtering or not.

Ultimately my end goal is to get the list of commits between given datetime time-range.

niharmkn commented 9 months ago

@gonchik or team can you please look at this as it is the blocker for me?

djgoku commented 9 months ago

repository.commits.get("7d947c8a7c70bc72d8e77f0d1010a380ccf7c03f") is what you are looking for.

Spacetown commented 9 months ago

Ultimately my end goal is to get the list of commits between given datetime time-range.

But this is something complete different from filtering by a commit hash.

You need something like:

for commit in repository.commits.each(q='created_on > 2015-10-04T14:00:00-07:00'):
    print(f'Commit: \n {commit.data["hash"]}\n')
niharmkn commented 9 months ago

Ultimately my end goal is to get the list of commits between given datetime time-range.

But this is something complete different from filtering by a commit hash.

You need something like:

for commit in repository.commits.each(q='created_on > 2015-10-04T14:00:00-07:00'):
    print(f'Commit: \n {commit.data["hash"]}\n')

@Spacetown , Thanks for the prompt reply,

Yes you are right, I have just provided the example to point out that querying is not working for the hash, date etc..

And in commits I don't think there is any created_on field.

niharmkn commented 9 months ago

repository.commits.get("7d947c8a7c70bc72d8e77f0d1010a380ccf7c03f ") is what you are looking for.

No, that is just for the reference that querying is not working, I want to filter out commits based on given date range

Spacetown commented 9 months ago

@niharmkn You're right, it's date. The argument is given to the paged API as it's documented by Atlassian.

niharmkn commented 9 months ago

@niharmkn You're right, it's date. The argument is given to the paged API as it's documented by Atlassian.

@Spacetown may I know how can I achieve the commit filtaration based on date field? As I had tried by querying on date field but not able to fetch the filtered data.

djgoku commented 9 months ago

I don't think you can filter by date using bitbucket api[1]. So you will have to do this from your application.

[1] https://jira.atlassian.com/browse/BCLOUD-22613

niharmkn commented 9 months ago

@djgoku library supports for the querying and seems that functionality of querying for each function in commits was not working for any of the commit field. Is there any workaround or fix you can apply for that? As the manual filtration was not a good approach at all

djgoku commented 9 months ago

@djgoku library supports for the querying and seems that functionality of querying for each function in commits was not working for any of the commit field. Is there any workaround or fix you can apply for that? As the manual filtration was not a good approach at all

The only filtering that can be done is using include, exclude and path which I don't think we support currently [1]. It looks like if you want to filter by author, date or something else you will have to do this in your client application.

[1] https://developer.atlassian.com/cloud/bitbucket/rest/api-group-commits/#api-repositories-workspace-repo-slug-commits-get

Spacetown commented 9 months ago

@djgoku library supports for the querying and seems that functionality of querying for each function in commits was not working for any of the commit field. Is there any workaround or fix you can apply for that? As the manual filtration was not a good approach at all

We forward the query only to the API. If the API doesn't support it we can't do anything. @gonchik Maybe the q parameter should be removed or a warning should be logged.