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

How to fetch list of commits between a given date and a commit ID?

Kaushik Veluru
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 23, 2023

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

1 answer

0 votes
Erez Maadani
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 23, 2023

Hi @Kaushik Veluru 

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

Kaushik Veluru
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 23, 2023

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. 

Christian Glockner
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 23, 2023

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

Kaushik Veluru
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 24, 2023

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?

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events