tests: add .gitignore files upon dvc_add (#3455)

This commit is contained in:
Paweł Redzyński
2020-03-13 17:19:35 +02:00
committed by GitHub
parent 682275dc0a
commit 767433d7a4
2 changed files with 27 additions and 1 deletions
+12 -1
View File
@@ -156,7 +156,18 @@ class TmpDir(pathlib.Path):
stages = self.dvc.add(filenames)
if commit:
stage_paths = [s.path for s in stages]
self.scm_add(stage_paths, commit=commit)
def to_gitignore(stage_path):
from dvc.scm import Git
return os.path.join(os.path.dirname(stage_path), Git.GITIGNORE)
gitignores = [
to_gitignore(s)
for s in stage_paths
if os.path.exists(to_gitignore(s))
]
self.scm_add(stage_paths + gitignores, commit=commit)
return stages