Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Raw diff/patch from bitbucket server api

Edited

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 Jul 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
Community showcase
Published in Bitbucket

New improvements to user management in Bitbucket Cloud 👥

Hey Community! We’re willing to wager that quite a few of you not only use Bitbucket, but administer it too. Our team is excited to share that we’ll be releasing improvements throughout this month of...

4,385 views 12 15
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you