| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 03b5db2 commit 0d8d845
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1133,6 +1133,7 @@ def move( | |||
| 1133 | 1133 | args = [] | |
| 1134 | 1134 | if skip_errors: | |
| 1135 | 1135 | args.append("-k") | |
| 1136 | + args.append("--") | ||
| 1136 | 1137 | ||
| 1137 | 1138 | paths = self._items_to_rela_paths(items) | |
| 1138 | 1139 | if len(paths) < 2: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1137,7 +1137,7 @@ def ignored(self, *paths: PathLike) -> List[str]: | |||
| 1137 | 1137 | Subset of those paths which are ignored | |
| 1138 | 1138 | """ | |
| 1139 | 1139 | try: | |
| 1140 | - proc: str = self.git.check_ignore(*paths) | ||
| 1140 | + proc: str = self.git.check_ignore("--", *paths) | ||
| 1141 | 1141 | except GitCommandError as err: | |
| 1142 | 1142 | if err.status == 1: | |
| 1143 | 1143 | # If return code is 1, this means none of the items in *paths are | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -80,3 +80,41 @@ def test_remote_ref_delete_preserves_operand(tmp_path): | |||
| 80 | 80 | with mock.patch.object(Git, "_call_process") as run: | |
| 81 | 81 | RemoteReference.delete(repo, ref) | |
| 82 | 82 | assert run.call_args[0] == ("branch", "-d", "-r", "--", ref) | |
| 83 | + | ||
| 84 | + | ||
| 85 | + def test_move_treats_option_shaped_source_as_filename(tmp_path): | ||
| 86 | + repo = Repo.init(tmp_path) | ||
| 87 | + (tmp_path / "--force").write_text("literal source") | ||
| 88 | + repo.index.add(["--force"]) | ||
| 89 | + assert repo.index.move(["--force", "destination"]) == [("--force", "destination")] | ||
| 90 | + assert (tmp_path / "destination").read_text() == "literal source" | ||
| 91 | + assert not (tmp_path / "--force").exists() | ||
| 92 | + | ||
| 93 | + | ||
| 94 | + def test_move_cannot_override_overwrite_protection(tmp_path): | ||
| 95 | + repo = Repo.init(tmp_path) | ||
| 96 | + for name in ("--force", "source", "destination"): | ||
| 97 | + (tmp_path / name).write_text(name) | ||
| 98 | + repo.index.add(["--force", "source", "destination"]) | ||
| 99 | + with pytest.raises(GitCommandError): | ||
| 100 | + repo.index.move(["--force", "source", "destination"]) | ||
| 101 | + assert (tmp_path / "source").read_text() == "source" | ||
| 102 | + assert (tmp_path / "destination").read_text() == "destination" | ||
| 103 | + repo.index.move(["source", "destination"], force=True) | ||
| 104 | + assert (tmp_path / "destination").read_text() == "source" | ||
| 105 | + | ||
| 106 | + | ||
| 107 | + def test_ignored_treats_option_shaped_path_as_filename(tmp_path): | ||
| 108 | + repo = Repo.init(tmp_path) | ||
| 109 | + (tmp_path / ".gitignore").write_text("--verbose\n--arg value\n") | ||
| 110 | + assert repo.ignored("--verbose", "--arg value") == ["--verbose", "--arg value"] | ||
| 111 | + | ||
| 112 | + | ||
| 113 | + def test_move_cannot_override_dry_run(tmp_path): | ||
| 114 | + repo = Repo.init(tmp_path) | ||
| 115 | + (tmp_path / "source").write_text("source") | ||
| 116 | + repo.index.add(["source"]) | ||
| 117 | + with pytest.raises(GitCommandError): | ||
| 118 | + repo.index.move(["--no-dry-run", "source", "destination"], dry_run=True) | ||
| 119 | + assert (tmp_path / "source").read_text() == "source" | ||
| 120 | + assert not (tmp_path / "destination").exists() | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments