I would like to get all the commits before a given commit ID until a specified date like Jan 1st, 2023 using BitBucket Server REST API. Since & until parameters only accepts another commit ID but doesn't take a date.
a timestamp is accepted for since & until in GitHub & GitLab REST APIs to fetch a list of commits
Try using the git command: git rev-list
For example, this command will print all commits since 2 days ago up to the HEAD commit:
git rev-list --since=2.days.ago HEAD
Thank you for your response @Erez Maadani
Sorry for not clarifying that I need to fetch this information using REST API.
Do you know if there is a REST API available to do this? I am using Bitbucket Server.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Kaushik,
The Bitbucket Server REST API doesn't accept dates for listing commits, but if you know the commit ID you want to start from, you can use https://docs.atlassian.com/bitbucket-server/rest/5.16.0/bitbucket-rest.html#idm8283059808
Cheers,
Christian
Premier Support Engineer
Atlassian
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Christian,
Thank you for your response. We are working on an initiative that needs to pull all the commits before a given commit across all repositories and all instances within the organization. We are able to successfully do it for GitLab and GitHub but not for BitBucket.
GitLab API - https://docs.gitlab.com/ee/api/commits.html (Accepts date for Since)
GitHub API - https://docs.github.com/en/rest/commits/commits?apiVersion=2022-11-28#list-commits (Accepts date for Since)
We wouldn't know the commit ID where we want to start from?
Is there any way to achieve this?
Or is there an easy way to know the first commit ID on a repo for a given date?
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.