mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-07 07:18:27 +01:00
scm: implement gitignore (#5243)
* scm: implement gitignore; use `pygit2` backend * Add is_ignored implementation on `pygit2` and `gitpython` backends. * Also implement `._reset()` on `repo.scm` which is most of the changes. * fix tests * use _backend_func * minor fixups
This commit is contained in:
@@ -5,7 +5,7 @@ import os
|
||||
from functools import partial
|
||||
from typing import Callable, Iterable, Mapping, Optional, Tuple
|
||||
|
||||
from funcy import first
|
||||
from funcy import first, ignore
|
||||
|
||||
from dvc.progress import Tqdm
|
||||
from dvc.scm.base import CloneError, RevError, SCMError
|
||||
@@ -111,8 +111,11 @@ class GitPythonBackend(BaseGitBackend): # pylint:disable=abstract-method
|
||||
def git(self):
|
||||
return self.repo.git
|
||||
|
||||
def is_ignored(self, path):
|
||||
raise NotImplementedError
|
||||
def is_ignored(self, path: str) -> bool:
|
||||
from git.exc import GitCommandError
|
||||
|
||||
func = ignore(GitCommandError)(self.repo.git.check_ignore)
|
||||
return bool(func(path))
|
||||
|
||||
@property
|
||||
def root_dir(self) -> str:
|
||||
|
||||
Reference in New Issue
Block a user