[BB] Detecting PRs with Conflicts
I have been using this to get the status if a PR is conflicted or not:
for work_space in cloud.workspaces.each():
for project in work_space.projects.each():
print(f'Checking repositories in: \'{project.name}\'.')
for repository in project.repositories.each():
print(f'Checking pull requests in: \'{repository.name}\'.')
for pull_request in repository.pullrequests.each():
print(pull_request.has_conflict)
under the covers the property has_conflict calls this in your library which then in turns checks the status of each diff stat:
@property
def has_conflict(self):
"""Returns True if any of the changes in the PR cause conflicts."""
for diffstat in self.diffstat():
if diffstat.has_conflict:
return True
return False
@property
def has_conflict(self):
"""True if the change causes a conflict."""
return str(self.get_data("status")) in [
self.MERGE_CONFLICT,
self.RENAME_CONFLICT,
self.RENAME_DELETE_CONFLICT,
self.SUBREPO_CONFLICT,
self.LOCAL_DELETED,
self.REMOTE_DELETED,
]
But it appears that BB never seems to mark the status in the diff stats as anything but modified or created:
This diff represents the one in conflict according to the UI:
{
"lines_added": 3,
"lines_removed": 1,
"new": {
...
},
"old": {
...
},
"status": "modified",
"type": "diffstat"
}
but the web interface shows it as being conflicted:

Any ideas how to get if a PR has a conflict?
Hi @RtypeStudios , how it reflect in UI? I mean can you check the problem via ui? maybe you can find response which will help. Meanwhile I will look possible solution as well
Hi @gonchik
The UI makes a call to here to check for conflicts:
https://bitbucket.org/!api/internal/repositories/
This URL appears to return a JSON document containing details of the conflict.
Guessing from the "Internal" bit this isn't accessible to us mere mortals?
Apologies on the delay in my response, holidays and the initial start of year rush.
@RtypeStudios I think we can wrap it as experimental and internal request. also I see it works, I will be happy if you send a pull request
I've tried calling it, but haven't been able to make it work. Will investigate further and report back here if I can get it working. But so far now it appears you cannot check if a PR has a conflict via the API.
@RtypeStudios @gonchik Have you managed to find a workaround for this? I'm facing the same issue.
Sadly not, I've been waiting for Atlassian to add an API endpoint for it. It's a huge pain.
On Wed, Sep 6, 2023 at 6:13 PM Arsen Šekularac @.***> wrote:
@RtypeStudios https://github.com/RtypeStudios @gonchik https://github.com/gonchik Have you managed to find a workaround for this? I'm facing the same issue.
— Reply to this email directly, view it on GitHub https://github.com/atlassian-api/atlassian-python-api/issues/1099#issuecomment-1708058791, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAHRXIXVG2JCB6ED5NCQQF3XZBEEDANCNFSM6AAAAAAS43J35Q . You are receiving this because you were mentioned.Message ID: @.***>