check-ignore show sub-repo patterns (#4564)

* `check-ignore` show sub-repo patterns

fix #4555
1. Sub-repo pattern now would be considered in `check-ignore` command.
2. New outputs for sub-repo patterns in a `detail`
3. Related tests.

* message change
This commit is contained in:
karajan1001
2020-09-15 06:59:41 +03:00
committed by GitHub
parent bc5611968f
commit 5e69e29b2f
2 changed files with 10 additions and 3 deletions
+4 -1
View File
@@ -233,7 +233,10 @@ class DvcIgnoreFilter:
self._ignored_subrepos[root] = self._ignored_subrepos.get(
root, set()
) | {d}
new_pattern = DvcIgnorePatterns([f"/{d}/"], root)
pattern_info = PatternInfo(
f"/{d}/", "in sub_repo:{}".format(d)
)
new_pattern = DvcIgnorePatterns([pattern_info], root)
old_pattern = self.ignores_trie_tree.longest_prefix(root).value
if old_pattern:
self.ignores_trie_tree[root] = DvcIgnorePatterns(
+6 -2
View File
@@ -83,12 +83,16 @@ def test_check_ignore_out_side_repo(tmp_dir, dvc):
assert main(["check-ignore", "-q", "../file"]) == 1
def test_check_ignore_sub_repo(tmp_dir, dvc):
def test_check_ignore_sub_repo(tmp_dir, dvc, caplog):
tmp_dir.gen(
{DvcIgnore.DVCIGNORE_FILE: "other", "dir": {".dvc": {}, "foo": "bar"}}
)
assert main(["check-ignore", "-q", os.path.join("dir", "foo")]) == 1
assert main(["check-ignore", "-d", os.path.join("dir", "foo")]) == 0
assert (
"in sub_repo:{}\t{}".format("dir", os.path.join("dir", "foo"),)
in caplog.text
)
def test_check_sub_dir_ignore_file(tmp_dir, dvc, caplog):