mirror of
				https://github.com/arcan1s/ahriman.git
				synced 2025-11-03 23:33:41 +00:00 
			
		
		
		
	handle exceptions in actual_version calls
This commit is contained in:
		@ -218,20 +218,25 @@ class Package:
 | 
				
			|||||||
        logger = logging.getLogger("build_details")
 | 
					        logger = logging.getLogger("build_details")
 | 
				
			||||||
        Task.fetch(clone_dir, self.git_url)
 | 
					        Task.fetch(clone_dir, self.git_url)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        # update pkgver first
 | 
					        try:
 | 
				
			||||||
        Package._check_output("makepkg", "--nodeps", "--nobuild", exception=None, cwd=clone_dir, logger=logger)
 | 
					            # update pkgver first
 | 
				
			||||||
        # generate new .SRCINFO and put it to parser
 | 
					            Package._check_output("makepkg", "--nodeps", "--nobuild", exception=None, cwd=clone_dir, logger=logger)
 | 
				
			||||||
        srcinfo_source = Package._check_output(
 | 
					            # generate new .SRCINFO and put it to parser
 | 
				
			||||||
            "makepkg",
 | 
					            srcinfo_source = Package._check_output(
 | 
				
			||||||
            "--printsrcinfo",
 | 
					                "makepkg",
 | 
				
			||||||
            exception=None,
 | 
					                "--printsrcinfo",
 | 
				
			||||||
            cwd=clone_dir,
 | 
					                exception=None,
 | 
				
			||||||
            logger=logger)
 | 
					                cwd=clone_dir,
 | 
				
			||||||
        srcinfo, errors = parse_srcinfo(srcinfo_source)
 | 
					                logger=logger)
 | 
				
			||||||
        if errors:
 | 
					            srcinfo, errors = parse_srcinfo(srcinfo_source)
 | 
				
			||||||
            raise InvalidPackageInfo(errors)
 | 
					            if errors:
 | 
				
			||||||
 | 
					                raise InvalidPackageInfo(errors)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return self.full_version(srcinfo.get("epoch"), srcinfo["pkgver"], srcinfo["pkgrel"])
 | 
					            return self.full_version(srcinfo.get("epoch"), srcinfo["pkgver"], srcinfo["pkgrel"])
 | 
				
			||||||
 | 
					        except Exception:
 | 
				
			||||||
 | 
					            logger.exception("cannot determine version of VCS package, make sure that you have VCS tools installed")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return self.version
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def is_outdated(self, remote: Package, paths: RepositoryPaths) -> bool:
 | 
					    def is_outdated(self, remote: Package, paths: RepositoryPaths) -> bool:
 | 
				
			||||||
        """
 | 
					        """
 | 
				
			||||||
 | 
				
			|||||||
@ -97,11 +97,22 @@ def test_actual_version_vcs(package_tpacpi_bat_git: Package, repository_paths: R
 | 
				
			|||||||
    srcinfo = (resource_path_root / "models" / "package_tpacpi-bat-git_srcinfo").read_text()
 | 
					    srcinfo = (resource_path_root / "models" / "package_tpacpi-bat-git_srcinfo").read_text()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    mocker.patch("ahriman.models.package.Package._check_output", return_value=srcinfo)
 | 
					    mocker.patch("ahriman.models.package.Package._check_output", return_value=srcinfo)
 | 
				
			||||||
    mocker.patch("ahriman.core.build_tools.task.Task.fetch", return_value=None)
 | 
					    mocker.patch("ahriman.core.build_tools.task.Task.fetch")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    assert package_tpacpi_bat_git.actual_version(repository_paths) == "3.1.r13.g4959b52-1"
 | 
					    assert package_tpacpi_bat_git.actual_version(repository_paths) == "3.1.r13.g4959b52-1"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def test_actual_version_vcs_failed(package_tpacpi_bat_git: Package, repository_paths: RepositoryPaths,
 | 
				
			||||||
 | 
					                                   mocker: MockerFixture) -> None:
 | 
				
			||||||
 | 
					    """
 | 
				
			||||||
 | 
					    must return same version in case if exception occurred
 | 
				
			||||||
 | 
					    """
 | 
				
			||||||
 | 
					    mocker.patch("ahriman.models.package.Package._check_output", side_effect=Exception())
 | 
				
			||||||
 | 
					    mocker.patch("ahriman.core.build_tools.task.Task.fetch")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    assert package_tpacpi_bat_git.actual_version(repository_paths) == package_tpacpi_bat_git.version
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def test_is_outdated_false(package_ahriman: Package, repository_paths: RepositoryPaths) -> None:
 | 
					def test_is_outdated_false(package_ahriman: Package, repository_paths: RepositoryPaths) -> None:
 | 
				
			||||||
    """
 | 
					    """
 | 
				
			||||||
    must be not outdated for the same package
 | 
					    must be not outdated for the same package
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user