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

Raw diff/patch from bitbucket server api

Blake McAlevey-Scurr July 9, 2018

I have an application that needs the raw diff of a PR in the form that you would expect from `git diff <commitA> <commitB>`. But the Bitbucket Server API only seems to show diffs in a custom json format. Did I miss some way to query the raw diff? Or perhaps the json is a standard format I'm not aware of. I can always deal with it manually if need be. 

Raw example:

diff --git a/file2.test b/file2.test
new file mode 100644
index 0000000..75b3cd7
--- /dev/null
+++ b/file2.test
@@ -0,0 +1 @@
+ayyo

JSON example:

{
"fromHash": "eee37aed1be4acd61e3a62346a93aa77fc04487c",
"toHash": "937b78681510f8dfd0a9185f01109edc8ca99569",
"contextLines": 10,
"whitespace": "SHOW",
"diffs": [{
"source": null,
"destination": {
"components": ["file2.test"],
"parent": "",
"name": "file2.test",
"extension": "test",
"toString": "file2.test"
},
"hunks": [{
"sourceLine": 0,
"sourceSpan": 0,
"destinationLine": 1,
"destinationSpan": 1,
"segments": [{
"type": "ADDED",
"lines": [{
"source": 0,
"destination": 1,
"line": "ayyo",
"truncated": false
}],
"truncated": false
}],
"truncated": false
}],
"truncated": false
}],
"truncated": false
}

 edit: formatting

1 answer

0 votes
Aaron
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 11, 2018

Hello Blake,

 

Welcome to the Atlassian Community!

 

Most APIs usually return it's payload in JSON format as far as I know, but that is what we parse to display data on the page. But if your application requires the typical git diff return, is it possible to simply run the git diff from your application? You could give it a user in Bitbucket server to have separate credentials and it can clone and run git diff on its own.

 

Regards,
Aaron Levinson
Dev Tools Support Engineer

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events