I want to get the difference between the code when pulling the commits via development API,
I got the list of issues and then the list of commits that are related to the Jira Issue, but I could not get the exact source code.
Hello @Bashayer Alsalman and welcome to the Community!
As you mentioned you were already able to get the list of issues and their related commits, if you want to compare the diff between commits, the Compare two commits endpoint can be used:
https://api.bitbucket.org/2.0/repositories/<workspace>/<repository>/diff/<spec>
Where the spec parameter can be a commit id, a branch name, or a tag.
Following is an example request to get the diff between two commits :
curl -X GET -u USERNAME:APP_PASSWORD https://api.bitbucket.org/2.0/repositories/<workspace>/<repository>/diff/aa35f95..259de05
This should return the diff between the source commit and the merge base of the source commit and the destination commit.
However, if you want to get the content of files/directories within the repository, then the Get file of directory contents endpoint might be useful. Below is an example request listing all the files and directories up to max_depth in commit 259de05
https://api.bitbucket.org/2.0/repositories/<workspace>/<repository>/src/259de05/?max_depth=10
The max_depth will control the number of nested directories that will be returned. The object returned from this API will just contain the list of the files/directories. If you would like to get the actual raw content of a file, you will need to follow the links.self.href of each file entry returned in the JSON.
Hope that helps! Let me know in case you have any questions.
Thank you, @Bashayer Alsalman !
Patrik S
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.