예제 #1
0
    async def get_existing_duplicate_pull(
        cls, ctxt: context.Context, branch_name: github_types.GitHubRefType
    ) -> typing.Optional[github_types.GitHubPullRequest]:
        bp_branch = duplicate_pull.get_destination_branch_name(
            ctxt.pull["number"], branch_name, cls.BRANCH_PREFIX
        )
        pulls = [
            pull
            async for pull in typing.cast(
                typing.AsyncGenerator[github_types.GitHubPullRequest, None],
                ctxt.client.items(
                    f"{ctxt.base_url}/pulls",
                    resource_name="pulls",
                    page_limit=10,
                    params={
                        "base": branch_name,
                        "sort": "created",
                        "state": "all",
                        "head": f"{ctxt.pull['base']['user']['login']}:{bp_branch}",
                    },
                ),
            )
        ]

        return pulls[-1] if pulls else None
예제 #2
0
 def get_existing_duplicate_pull(cls, pull, branch):
     bp_branch = duplicate_pull.get_destination_branch_name(
         pull, branch, cls.KIND)
     # NOTE(sileht): Github looks buggy here, head= doesn't work as expected
     pulls = list(p for p in pull.g_pull.base.repo.get_pulls(
         base=branch.name, sort="created", state="all")
                  if p.head.ref == bp_branch)
     if pulls:
         return pulls[-1]
예제 #3
0
 def get_existing_duplicate_pull(cls, ctxt, branch_name):
     bp_branch = duplicate_pull.get_destination_branch_name(
         ctxt.pull["number"], branch_name, cls.KIND)
     pulls = list(
         ctxt.client.items(
             f"{ctxt.base_url}/pulls",
             base=branch_name,
             sort="created",
             state="all",
             head=f"{ctxt.pull['base']['user']['login']}:{bp_branch}",
         ))
     if pulls:
         return pulls[-1]