mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-02 07:18:25 +01:00
* state: use ignore file handler when accessing metadata * fs: don't add dir size to overall size for dir * ignore: use posix-like path on windows * ignore: remove tree from dvc_walk arguments * ignore: handle DvcIgnoreFilter creation outside of DVC repo * ignore: throw on dvcignore file under output dir, but not dependency dir * ignore: move ignore initialization to Repo init * ignore: work in progress * ignore: work in progress 2 * ignore: throw on .dvcignore upon collecting dir * ignore: refactor * ignore: loading upper level ignores in stages() * Update dvc/repo/__init__.py Co-Authored-By: Ruslan Kuprieiev <[email protected]> * dvcignore review refactor
47 lines
986 B
Python
47 lines
986 B
Python
import os
|
|
from filecmp import dircmp
|
|
|
|
from dvc.scm import Git
|
|
from mock import MagicMock
|
|
from contextlib import contextmanager
|
|
|
|
|
|
def spy(method_to_decorate):
|
|
mock = MagicMock()
|
|
|
|
def wrapper(self, *args, **kwargs):
|
|
mock(*args, **kwargs)
|
|
return method_to_decorate(self, *args, **kwargs)
|
|
|
|
wrapper.mock = mock
|
|
return wrapper
|
|
|
|
|
|
def get_gitignore_content():
|
|
with open(Git.GITIGNORE, "r") as gitignore:
|
|
return gitignore.read().splitlines()
|
|
|
|
|
|
@contextmanager
|
|
def cd(newdir):
|
|
prevdir = os.getcwd()
|
|
os.chdir(os.path.expanduser(newdir))
|
|
try:
|
|
yield
|
|
finally:
|
|
os.chdir(prevdir)
|
|
|
|
|
|
def trees_equal(dir_path_1, dir_path_2):
|
|
|
|
comparison = dircmp(dir_path_1, dir_path_2)
|
|
|
|
assert set(comparison.left_only) == set(comparison.right_only) == set()
|
|
|
|
for d in comparison.common_dirs:
|
|
trees_equal(os.path.join(dir_path_1, d), os.path.join(dir_path_2, d))
|
|
|
|
|
|
def to_posixpath(path):
|
|
return path.replace("\\", "/")
|