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

Bitbucket Cloud - Check if a pull request has conflicts

Paolo.Ascari
Contributor
May 16, 2023

Hello, using the Bitbucket CLOUD API:

  • Is there a way to check if a pull request has any conflicting files - and if so, obtain a list thereof?

Thanks in advance for any pointers!

2 answers

1 accepted

1 vote
Answer accepted
Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 17, 2023

Hi Paolo and welcome to the community!

You can use the following API endpoint with the branches of the PR and without the topic query parameter

Example:

https://api.bitbucket.org/2.0/repositories/workspace-id/repo-slug/diffstat/feature..main

For the conflicted files, you will see in the output the field "status": "merge conflict".


The topic query parameter was introduced last year when we made changes in the diff algorithm we use:

The status "merge conflict" was not added as a status when the topic query is used, because we will eventually remove this status. When we do, we will provide a public conflict API endpoint for customers who use this status for that purpose, to ensure continuity.

Any changes in the API are announced here:

Kind regards,
Theodora

Paolo.Ascari
Contributor
May 17, 2023

Hello Theodora, and thank you for your prompt reply.

This!... Exactly what I was looking for!

But please let me ask you: is there a more comprehensive documentation detailing payloads and responses, including for example the 'status' field that you have mentioned and its possible values?

I have found the API documentation to be fairly basic, to be honest, sometimes with broken links or poorly formatted examples. I guess many things can be discovered through trial-and-error attempts, but it would be nice to have a richer/better documentation to peruse -- and avoid me asking you silly questions... ;)

Cheers, Paolo

Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 22, 2023

Hi Paolo,

That is the official documentation for our APIs. I just realized I provided the link to the diff endpoint instead of the diffstat, I edited my previous post to correct the URL.

While viewing info for this endpoint, scroll down to the section Responses (right below Example) > select Paginated Diff Stat, and a new window will open with details on the fields that are returned from this endpoint:

Screenshot 2023-05-22 at 10.36.08.png


If you scroll down this window, select Diff Stat (right below the field values) and you will see more fields documented (including the field status).

Please keep in mind that the status "merge conflict" is not documented there, because, as I mentioned, we will eventually remove it (it is also not available when using the topic query parameter).

Kind regards,
Theodora

Paolo.Ascari
Contributor
May 30, 2023

Thank you Theodora

Yes, I was looking for "merge conflict" as a possible value for the status field, but now I understand why it's not listed -- hopefully the new public conflict API endpoint will be available soon :)

Cheers,

Paolo

Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 30, 2023

You are welcome Paolo, please feel free to reach out if you ever need anything else!

Kind regards,
Theodora

0 votes
Ulrich Kuhnhardt _IzymesCo_
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
May 16, 2023

Hi @Paolo.Ascari ,

me again :)

There is a Bitbucket cloud API endpoint that merges  a PR [1]. I am not sure if you could swap the POST method with a GET and see if you get the mergeability status?

Would be interesting, I haven't tried this yet.

Best, Ulrich

 

[1] https://developer.atlassian.com/cloud/bitbucket/rest/api-group-pullrequests/#api-repositories-workspace-repo-slug-pullrequests-pull-request-id-merge-post

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
TAGS
AUG Leaders

Atlassian Community Events