diff --git a/src/ahriman/core/gitremote/remote_push.py b/src/ahriman/core/gitremote/remote_push.py index b66228b6..9b9f1e1f 100644 --- a/src/ahriman/core/gitremote/remote_push.py +++ b/src/ahriman/core/gitremote/remote_push.py @@ -81,7 +81,8 @@ class RemotePush(LazyLogging): # ...secondly, we clone whole tree... Sources.fetch(package_target_dir, package.remote) # ...and last, but not least, we remove the dot-git directory... - shutil.rmtree(package_target_dir / ".git", ignore_errors=True) + for git_file in package_target_dir.glob(".git*"): + shutil.rmtree(package_target_dir / git_file) # ...copy all patches... for patch in self.database.patches_get(package.base): filename = f"ahriman-{package.base}.patch" if patch.key is None else f"ahriman-{patch.key}.patch" diff --git a/tests/ahriman/core/gitremote/test_remote_push.py b/tests/ahriman/core/gitremote/test_remote_push.py index fb971b3c..41ad2f1e 100644 --- a/tests/ahriman/core/gitremote/test_remote_push.py +++ b/tests/ahriman/core/gitremote/test_remote_push.py @@ -20,18 +20,21 @@ def test_package_update(database: SQLite, configuration: Configuration, package_ """ patch1 = PkgbuildPatch(None, "patch") patch2 = PkgbuildPatch("key", "value") + local = Path("local") + glob_mock = mocker.patch("pathlib.Path.glob", return_value=[".git", ".gitignore"]) rmtree_mock = mocker.patch("shutil.rmtree") fetch_mock = mocker.patch("ahriman.core.build_tools.sources.Sources.fetch") patches_mock = mocker.patch("ahriman.core.database.SQLite.patches_get", return_value=[patch1, patch2]) patches_write_mock = mocker.patch("ahriman.models.pkgbuild_patch.PkgbuildPatch.write") runner = RemotePush(configuration, database, "gitremote") - local = Path("local") assert runner.package_update(package_ahriman, local) == package_ahriman.base + glob_mock.assert_called_once_with(".git*") rmtree_mock.assert_has_calls([ MockCall(local / package_ahriman.base, ignore_errors=True), - MockCall(local / package_ahriman.base / ".git", ignore_errors=True), + MockCall(local / package_ahriman.base / ".git"), + MockCall(local / package_ahriman.base / ".gitignore"), ]) fetch_mock.assert_called_once_with(pytest.helpers.anyvar(int), package_ahriman.remote) patches_mock.assert_called_once_with(package_ahriman.base)