mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-02 07:18:25 +01:00
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:
+4
-1
@@ -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(
|
||||
|
||||
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user