Skip to content

[BB] Detecting PRs with Conflicts #1099

Open
@RtypeStudios

Description

@RtypeStudios

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:

image

Any ideas how to get if a PR has a conflict?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bitbucketAtlassian Bitbucket (Cloud or Server)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions