def local_project(self): """ return an instance of LocalProject """ if self._local_project is None: pagure_service = PagureService( token=self.pagure_user_token, instance_url=self.package_config.dist_git_base_url, read_only=self.config.dry_run, ) if self.package_config.dist_git_clone_path: self._local_project = LocalProject( working_dir=self.package_config.dist_git_clone_path, git_url=self.package_config.dist_git_package_url, namespace=self.package_config.dist_git_namespace, repo_name=self.package_config.downstream_package_name, git_service=pagure_service, ) else: tmpdir = tempfile.mkdtemp(prefix="packit-dist-git") f = FedPKG(fas_username=self.fas_user, directory=tmpdir) f.init_ticket(self.config.keytab_path) f.clone( self.package_config.downstream_package_name, tmpdir, anonymous=not cccolutils.has_creds(), ) self._local_project = LocalProject( working_dir=tmpdir, git_url=self.package_config.dist_git_package_url, namespace=self.package_config.dist_git_namespace, repo_name=self.package_config.downstream_package_name, git_service=pagure_service, ) self._local_project.working_dir_temporary = True return self._local_project
def local_project(self): """ return an instance of LocalProject """ if self._local_project is None: dist_git_project = self.config.get_project( url=self.package_config.dist_git_package_url ) if self.package_config.dist_git_clone_path: self._local_project = LocalProject( working_dir=self.package_config.dist_git_clone_path, git_url=self.package_config.dist_git_package_url, namespace=self.package_config.dist_git_namespace, repo_name=self.package_config.downstream_package_name, git_project=dist_git_project, ) else: tmpdir = tempfile.mkdtemp(prefix="packit-dist-git") f = FedPKG( fas_username=self.fas_user, directory=tmpdir, stage=self.stage ) f.clone( self.package_config.downstream_package_name, tmpdir, anonymous=not cccolutils.has_creds(), ) self._local_project = LocalProject( working_dir=tmpdir, git_url=self.package_config.dist_git_package_url, namespace=self.package_config.dist_git_namespace, repo_name=self.package_config.downstream_package_name, git_project=dist_git_project, ) self._local_project.working_dir_temporary = True self._local_project.refresh_the_arguments() elif not self._local_project.git_project: self._local_project.git_project = self.config.get_project( url=self.package_config.dist_git_package_url ) self._local_project.refresh_the_arguments() return self._local_project
def test_fedpkg_clone(self): """ test `fedpkg clone -a` within an openshift pod """ t = Path(self.tmpdir) f = FedPKG() f.clone("units", str(t), anonymous=True) assert t.joinpath("units.spec").is_file()