mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-19 23:11:44 +01:00
git: implement dulwich add --update (#5491)
* dulwich: implement add with --update * add git backend test for add() * fix list comprehension in dulwich status() * allow adding single string path instead of list * handle windows paths in add(update=...)
This commit is contained in:
@@ -3,7 +3,7 @@ import locale
|
||||
import logging
|
||||
import os
|
||||
from functools import partial
|
||||
from typing import Callable, Iterable, List, Mapping, Optional, Tuple
|
||||
from typing import Callable, Iterable, List, Mapping, Optional, Tuple, Union
|
||||
|
||||
from funcy import first, ignore
|
||||
|
||||
@@ -188,11 +188,13 @@ class GitPythonBackend(BaseGitBackend): # pylint:disable=abstract-method
|
||||
def dir(self) -> str:
|
||||
return self.repo.git_dir
|
||||
|
||||
def add(self, paths: Iterable[str], update=False):
|
||||
def add(self, paths: Union[str, Iterable[str]], update=False):
|
||||
# NOTE: GitPython is not currently able to handle index version >= 3.
|
||||
# See https://github.com/iterative/dvc/issues/610 for more details.
|
||||
try:
|
||||
if update:
|
||||
if isinstance(paths, str):
|
||||
paths = [paths]
|
||||
self.git.add(*paths, update=True)
|
||||
else:
|
||||
self.repo.index.add(paths)
|
||||
|
||||
Reference in New Issue
Block a user