def checkout_pr(self, pr_id: Union[str, int]) -> None: """ Fetch selected PR and check it out in a local branch `pr/{pr_id}`. Args: pr_id: ID of the PR we are merging. """ logger.info(f"Checking out PR {pr_id}.") is_gitlab = isinstance(self.git_service, GitlabService) or ( not self.git_service and get_service_class(self.git_url) == GitlabService) remote_ref = "+refs/{}/{}/head".format( "merge-requests" if is_gitlab else "pull", pr_id) remote_name = self.remote or "origin" local_ref = f"refs/remotes/{remote_name}/{LP_TEMP_PR_CHECKOUT_NAME}/{pr_id}" local_branch = f"{LP_TEMP_PR_CHECKOUT_NAME}/{pr_id}" self._fetch_as_branch(remote_ref, local_ref, local_branch) self.git_repo.branches[local_branch].checkout() head_commit = self.git_repo.branches[local_branch].commit logger.info( f"Checked out commit\n" f"({shorten_commit_hash(head_commit.hexsha)})\t{head_commit.summary}" )
def test_get_service_class_not_found(url, mapping): with pytest.raises(OgrException) as ex: _ = get_service_class(url=url, service_mapping_update=mapping) assert str(ex.value) == "No matching service was found."
def test_get_service_class(url, mapping, result): service = get_service_class(url=url, service_mapping_update=mapping) assert issubclass(result, service)