Hey.
How to get Information about PR conflict ith REST Api?
Hello @arturkremens,
Thanks for reaching out.
You can list files involved in the pull request using diffstat endpoint:
/2.0/repositories/{workspace}/{repo_slug}/pullrequests/{pull_request_id}/diffstat
Diff stat responses contain a record for every path modified by the PR. The field status will contain information about a conflict in that file diff, if there are any. Example response payload (I excluded some fields to make it smaller):
{ "values": [ { "status": "merge conflict", "old": { "path": "z.txt", "type": "commit_file" }, "lines_removed": 0, "lines_added": 4, "new": { "path": "z.txt", "type": "commit_file" }, "type": "diffstat" } ], "page": 1, "size": 1}
Now, if you need to find exact conflicting chunks you can get the diff of the PR in question using diff endpoint and get the unified diff back:
/2.0/repositories/{workspace}/{repo_slug}/pullrequests/{pull_request_id}/diff
It will contain markers for conflicts. Example response payload:
diff --git a/z.txt b/z.txtindex 443c26a..d2eab11 100644--- a/z.txt+++ b/z.txt+<<<<<<< destination:eace7ee877e62e0d85d6b59b6f3bcc8d6e63ca93Hello worldHello worldHello world@ Hello worldHello worldHello worldHello world+=======+What if+>>>>>>> source:92bd412da9b48d7bc34a5e295a073a20284d17fa
You can also limit it down to just one file by adding path query parameter:
/2.0/repositories/{workspace}/{repo_slug}/pullrequests/{pull_request_id}/diff?path={path_to_file}
I hope this is what you're after. Let me know if you have any questions.
Cheers,Daniil
It looks like you're new here. Sign in or register to get started.