diff --git a/copier/main.py b/copier/main.py index a40121f84..8d51d9455 100644 --- a/copier/main.py +++ b/copier/main.py @@ -898,7 +898,10 @@ def _apply_update(self): ignored_files = git["status", "--ignored", "--porcelain"]() # returns "!! file1\n !! file2\n" # extra_exclude will contain: ["file1", file2"] - extra_exclude = [filename.split('!! ').pop() for filename in ignored_files.split("\n")][:-1] + extra_exclude = [ + filename.split("!! ").pop() + for filename in ignored_files.splitlines() + ] for skip_pattern in chain( self.skip_if_exists, self.template.skip_if_exists, extra_exclude ): diff --git a/tests/test_updatediff.py b/tests/test_updatediff.py index fd69d556c..6073d394a 100644 --- a/tests/test_updatediff.py +++ b/tests/test_updatediff.py @@ -651,8 +651,8 @@ def test_file_removed(tmp_path_factory: pytest.TempPathFactory) -> None: git("tag", "2") # Subproject updates with local.cwd(dst): - # git ignore a file - Path(".git/info/exclude").write_text("toignore.txt") + Path(".gitignore").write_text("toignore.txt") + git("commit", "-Am", "ignore file") with pytest.raises( UserMessageError, match="Enable overwrite to update a subproject." ):