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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.