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

Need to get the changed,added,removed files between two commits

yashodperera May 17, 2023

Currently, when configuring a webhook to trigger on a code push event in Bitbucket Cloud, the payload does not include information about the specific files that have changed. Does Bitbucket Cloud provide a dedicated API endpoint to directly retrieve the changed, added, or deleted files between two commits? 

I have done some search and identified the following endpoint which includes all the changes which is not scalable. 

https://api.bitbucket.org/2.0/repositories/{workspace}/{repo}/diff/{commit1}..{commit2}

1 answer

0 votes
Patrik S
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 18, 2023

Hello @yashodperera ,

Thank you for reaching out to Atlassian Community!

I think what you are looking for can be achieved using the diff stat endpoint : 

This endpoint should return a JSON object containing all the files that were added,removed,modified or renamed by comparing two commits.

Following is an example of an API call using that endpoint, which will compare the files changed between two commits : 

curl -X GET -u USERNAME:APPPASSWORD https://api.bitbucket.org/2.0/repositories/<workspace>/<repository>/diffstat/f179ff7..00f0e77

 The first commit is the commit you want to see the changes. The second commit represents the state to which we want to compare the first commit.

If you provide only one commit ID to that endpoint, it will calculate the diff spec against the first parent of the specified commit.

Hope that helps! Let me know in case you have any questions.

Thank you, @yashodperera !

Patrik S

yashodperera May 21, 2023

Hi @Patrik S Thank you you are a lifesaver.

Like Patrik S likes this

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events