示例#1
0
 def _refresh_pulls(
     self,
     pull_requests_to_refresh: typing.List[
         github_types.GitHubPullRequestNumber],
 ) -> None:
     for pull in pull_requests_to_refresh:
         utils.async_run(
             github_events.send_refresh({
                 "number": pull,
                 "base": {
                     "repo": {
                         "name": self.repo,
                         "owner": {
                             "login": self.owner
                         },
                         "full_name": f"{self.owner}/{self.repo}",
                     }
                 },
             }  # type: ignore
                                        ))
示例#2
0
    def pull_request_auto_refresher(self, pull_number):
        # NOTE(sileht): we need to refresh PR for two reasons:
        # * sync the first one from its base branch if needed
        # * update all summary with the new queues

        old_pull_requests = self.get_pulls()
        try:
            yield
        finally:
            new_pull_requests = self.get_pulls()
            if new_pull_requests == old_pull_requests:
                return

            pull_requests_to_refresh = [
                p for p in new_pull_requests if p != pull_number
            ]
            if not pull_requests_to_refresh:
                return

            self.log.info(
                "queue changed, refreshing all pull requests",
                _from=old_pull_requests,
                _to=new_pull_requests,
                _to_refresh=pull_requests_to_refresh,
            )

            for pull in pull_requests_to_refresh:
                utils.async_run(
                    github_events.send_refresh({
                        "number": pull,
                        "base": {
                            "repo": {
                                "name": self.repo,
                                "owner": {
                                    "login": self.owner
                                },
                                "full_name": f"{self.owner}/{self.repo}",
                            }
                        },
                    }))
示例#3
0
    def pull_request_auto_refresher(self, pull_number):
        # NOTE(sileht): If the first queued pull request changes, we refresh it to sync
        # its base branch

        old_pull_requests = self.get_pulls()
        try:
            yield
        finally:
            if not old_pull_requests:
                return
            new_pull_requests = self.get_pulls()
            if not new_pull_requests:
                return

            if (
                new_pull_requests[0] != old_pull_requests[0]
                and new_pull_requests[0] != pull_number
            ):
                self.log.info(
                    "refreshing next pull in queue",
                    next_pull=new_pull_requests[0],
                    _from=old_pull_requests,
                    to=new_pull_requests,
                )
                asyncio.run(
                    github_events.send_refresh(
                        {
                            "number": new_pull_requests[0],
                            "base": {
                                "repo": {
                                    "name": self.repo,
                                    "owner": {"login": self.owner},
                                    "full_name": f"{self.owner}/{self.repo}",
                                }
                            },
                        }
                    )
                )
示例#4
0
 def run(self, ctxt, rule, missing_conditions) -> check_api.Result:
     asyncio.run(github_events.send_refresh(ctxt.pull))
     return check_api.Result(
         check_api.Conclusion.SUCCESS, title="Pull request refreshed", summary=""
     )
示例#5
0
 def run(self, ctxt: context.Context,
         rule: rules.EvaluatedRule) -> check_api.Result:
     asyncio.run(github_events.send_refresh(ctxt.pull))
     return check_api.Result(check_api.Conclusion.SUCCESS,
                             title="Pull request refreshed",
                             summary="")