mirror of
				https://github.com/arcan1s/ahriman.git
				synced 2025-10-30 21:33:43 +00:00 
			
		
		
		
	add patches to clean command
This commit is contained in:
		| @ -300,6 +300,7 @@ def _set_repo_clean_parser(root: SubParserAction) -> argparse.ArgumentParser: | ||||
|     parser.add_argument("--no-chroot", help="do not clear build chroot", action="store_true") | ||||
|     parser.add_argument("--no-manual", help="do not clear directory with manually added packages", action="store_true") | ||||
|     parser.add_argument("--no-packages", help="do not clear directory with built packages", action="store_true") | ||||
|     parser.add_argument("--no-patches", help="do not clear directory with patches", action="store_true") | ||||
|     parser.set_defaults(handler=handlers.Clean, quiet=True, unsafe=True) | ||||
|     return parser | ||||
|  | ||||
|  | ||||
| @ -162,7 +162,8 @@ class Application: | ||||
|         for name in names: | ||||
|             process_single(name) | ||||
|  | ||||
|     def clean(self, no_build: bool, no_cache: bool, no_chroot: bool, no_manual: bool, no_packages: bool) -> None: | ||||
|     def clean(self, no_build: bool, no_cache: bool, no_chroot: bool, no_manual: bool, no_packages: bool, | ||||
|               no_patches: bool) -> None: | ||||
|         """ | ||||
|         run all clean methods. Warning: some functions might not be available under non-root | ||||
|         :param no_build: do not clear directory with package sources | ||||
| @ -170,6 +171,7 @@ class Application: | ||||
|         :param no_chroot: do not clear build chroot | ||||
|         :param no_manual: do not clear directory with manually added packages | ||||
|         :param no_packages: do not clear directory with built packages | ||||
|         :param no_patches: do not clear directory with patches | ||||
|         """ | ||||
|         if not no_build: | ||||
|             self.repository.clear_build() | ||||
| @ -181,6 +183,8 @@ class Application: | ||||
|             self.repository.clear_manual() | ||||
|         if not no_packages: | ||||
|             self.repository.clear_packages() | ||||
|         if not no_patches: | ||||
|             self.repository.clear_patches() | ||||
|  | ||||
|     def remove(self, names: Iterable[str]) -> None: | ||||
|         """ | ||||
|  | ||||
| @ -41,5 +41,5 @@ class Clean(Handler): | ||||
|         :param configuration: configuration instance | ||||
|         :param no_report: force disable reporting | ||||
|         """ | ||||
|         Application(architecture, configuration, no_report).clean(args.no_build, args.no_cache, args.no_chroot, | ||||
|                                                                   args.no_manual, args.no_packages) | ||||
|         Application(architecture, configuration, no_report).clean( | ||||
|             args.no_build, args.no_cache, args.no_chroot, args.no_manual, args.no_packages, args.no_patches) | ||||
|  | ||||
| @ -76,3 +76,11 @@ class Cleaner(Properties): | ||||
|         self.logger.info("clear built packages directory") | ||||
|         for package in self.packages_built(): | ||||
|             package.unlink() | ||||
|  | ||||
|     def clear_patches(self) -> None: | ||||
|         """ | ||||
|         clear directory with patches | ||||
|         """ | ||||
|         self.logger.info("clear patches directory") | ||||
|         for package in self.paths.patches.iterdir(): | ||||
|             shutil.rmtree(package) | ||||
|  | ||||
| @ -17,6 +17,7 @@ def _default_args(args: argparse.Namespace) -> argparse.Namespace: | ||||
|     args.no_chroot = False | ||||
|     args.no_manual = False | ||||
|     args.no_packages = False | ||||
|     args.no_patches = False | ||||
|     return args | ||||
|  | ||||
|  | ||||
|  | ||||
| @ -212,7 +212,7 @@ def test_clean_build(application: Application, mocker: MockerFixture) -> None: | ||||
|     must clean build directory | ||||
|     """ | ||||
|     clear_mock = mocker.patch("ahriman.core.repository.cleaner.Cleaner.clear_build") | ||||
|     application.clean(False, True, True, True, True) | ||||
|     application.clean(False, True, True, True, True, True) | ||||
|     clear_mock.assert_called_once() | ||||
|  | ||||
|  | ||||
| @ -221,7 +221,7 @@ def test_clean_cache(application: Application, mocker: MockerFixture) -> None: | ||||
|     must clean cache directory | ||||
|     """ | ||||
|     clear_mock = mocker.patch("ahriman.core.repository.cleaner.Cleaner.clear_cache") | ||||
|     application.clean(True, False, True, True, True) | ||||
|     application.clean(True, False, True, True, True, True) | ||||
|     clear_mock.assert_called_once() | ||||
|  | ||||
|  | ||||
| @ -230,7 +230,7 @@ def test_clean_chroot(application: Application, mocker: MockerFixture) -> None: | ||||
|     must clean chroot directory | ||||
|     """ | ||||
|     clear_mock = mocker.patch("ahriman.core.repository.cleaner.Cleaner.clear_chroot") | ||||
|     application.clean(True, True, False, True, True) | ||||
|     application.clean(True, True, False, True, True, True) | ||||
|     clear_mock.assert_called_once() | ||||
|  | ||||
|  | ||||
| @ -239,7 +239,7 @@ def test_clean_manual(application: Application, mocker: MockerFixture) -> None: | ||||
|     must clean manual directory | ||||
|     """ | ||||
|     clear_mock = mocker.patch("ahriman.core.repository.cleaner.Cleaner.clear_manual") | ||||
|     application.clean(True, True, True, False, True) | ||||
|     application.clean(True, True, True, False, True, True) | ||||
|     clear_mock.assert_called_once() | ||||
|  | ||||
|  | ||||
| @ -248,7 +248,16 @@ def test_clean_packages(application: Application, mocker: MockerFixture) -> None | ||||
|     must clean packages directory | ||||
|     """ | ||||
|     clear_mock = mocker.patch("ahriman.core.repository.cleaner.Cleaner.clear_packages") | ||||
|     application.clean(True, True, True, True, False) | ||||
|     application.clean(True, True, True, True, False, True) | ||||
|     clear_mock.assert_called_once() | ||||
|  | ||||
|  | ||||
| def test_clean_patches(application: Application, mocker: MockerFixture) -> None: | ||||
|     """ | ||||
|     must clean packages directory | ||||
|     """ | ||||
|     clear_mock = mocker.patch("ahriman.core.repository.cleaner.Cleaner.clear_patches") | ||||
|     application.clean(True, True, True, True, True, False) | ||||
|     clear_mock.assert_called_once() | ||||
|  | ||||
|  | ||||
|  | ||||
| @ -82,3 +82,12 @@ def test_clear_packages(cleaner: Cleaner, mocker: MockerFixture) -> None: | ||||
|  | ||||
|     cleaner.clear_packages() | ||||
|     Path.unlink.assert_has_calls([mock.call(), mock.call(), mock.call()]) | ||||
|  | ||||
|  | ||||
| def test_clear_patches(cleaner: Cleaner, mocker: MockerFixture) -> None: | ||||
|     """ | ||||
|     must clear directory with patches | ||||
|     """ | ||||
|     _mock_clear(mocker) | ||||
|     cleaner.clear_patches() | ||||
|     _mock_clear_check() | ||||
|  | ||||
		Reference in New Issue
	
	Block a user