def test_get_project_github(self): project = get_project( url="https://github.com/packit-service/ogr", custom_instances=self.custom_instances, ) assert isinstance(project, GithubProject) assert project.github_repo
def _get_project(self, url: str) -> GitProject: try: project = get_project(url=url, custom_instances=self.services) except OgrException as ex: msg = f"Authentication for url '{url}' is missing in the config." logger.warning(msg) raise PackitConfigException(msg, ex) return project
def test_get_project_github(self): # unittest + pytest is a no-no for fixtures/parametrize urls = [ "https://github.com/packit/ogr", "[email protected]:TomasTomecek/speaks.git", ] for url in urls: project = get_project(url=url, custom_instances=self.custom_instances) assert isinstance(project, GithubProject) assert project.github_repo
def _get_project(self, url: str, get_project_kwargs: dict = None) -> GitProject: get_project_kwargs = get_project_kwargs or {} try: project = get_project(url=url, custom_instances=self.services, **get_project_kwargs) except OgrException as ex: msg = f"Authentication for url {url!r} is missing in the config." logger.warning(msg) raise PackitConfigException(msg, ex) return project
def get_project(self): """ Create ogr project instance based on provided configuration. Project instance is used for manipulating with Github/Pagure repo. :return: ogr Github/Pagure project instance or None """ return get_project(url=self.clone_url, custom_instances=[ GithubService(token=self.github_token), PagureService( token=self.pagure_token, instance_url=self.pagure_instance_url) ])
def get_project(self): """ Create ogr project instance based on provided configuration. Project instance is used for manipulating with Github/Pagure repo. :return: ogr Github/Pagure project instance or None """ # Return instance for github app if self.github_app_id: github_cert = Path(self.github_app_cert_path).read_text() if self.github_app_installation_id: # github token will be used as a credential over http (commit/push) github_app = GitHubApp(self.github_app_id, self.github_app_cert_path) self.github_token = github_app.get_installation_access_token( self.github_app_installation_id) return get_project( url=self.clone_url, custom_instances=[ GithubService( token=None, github_app_id=self.github_app_id, github_app_private_key=github_cert, ) ], ) # Return instance for regular user (local machine) return get_project( url=self.clone_url, custom_instances=[ GithubService(token=self.github_token), PagureService(token=self.pagure_token, instance_url=self.pagure_instance_url), ], )
def get_git_project(self, url: str) -> GitProject: if not url: url = self.guess_remote_url() return get_project(url, custom_instances=self.git_services)