2

I'm trying to find out an end point to get difference between two branches via BitBucket Rest API

branch 1: refs/heads/release/1.1
branch 2: refs/heads/release/1.2

However when i invoke GET request like

https://stash.xx.com:1111/rest/api/1.0/projects/MyProject/repos/repos1/compare/diff?targetBranch=refs%2Fheads%2Frelease%2F1.1&sourceBranch=refs%2Fheads%2Frelease%2F1.2&targetRepoId=123456

and HTTP 200 and empty json:

{
"fromHash": "refs/heads/master",
"toHash": "refs/heads/master",
"contextLines": 10,
"whitespace": "SHOW",
"diffs": [],
"truncated": false
}

the similar ULR i have when comparing the same branches via Bitbucket Web.

I believe i can retrieve commit/message info by:

git log --oneline refs/heads/release/1.2...refs/heads/release/1.1

but would like to use REST API not through calling git commands directly

Can you give me a hint what i missed?

Thank you

EDIT

Resulting JSON includes 'From' & 'To' default values (default branch) and that's why diff = []

So the issue was definitely in my request's parameters, server could not recognize my fromHash and toHash branches

RESOLVED

My bad: incorrect naming of parameters, instead of fromHash/ToHash just do what the Atlassian doc tells you (from, to)!

https://stash.xx.com:1111/rest/api/1.0/projects/MyProject/repos/repos1/compare/diff?from=refs%2Fheads%2Frelease%2F1.1&to=refs%2Fheads%2Frelease%2F1.2&targetRepoId=123456

To have difference in COMMITS just use the same request but /commits end point (not diff)

27P
  • 1,183
  • 16
  • 22

0 Answers0