mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-09 23:10:24 +01:00
Ensure relpath accepts str and Path-like objects
This commit is contained in:
+4
-5
@@ -429,14 +429,13 @@ class State(object): # pylint: disable=too-many-instance-attributes
|
||||
path_info (dict): path info to add to the list of links.
|
||||
"""
|
||||
assert path_info.scheme == "local"
|
||||
path = fspath_py35(path_info)
|
||||
|
||||
if not os.path.exists(path):
|
||||
if not os.path.exists(fspath_py35(path_info)):
|
||||
return
|
||||
|
||||
mtime, _ = get_mtime_and_size(path, self.repo.tree)
|
||||
inode = get_inode(path)
|
||||
relative_path = relpath(path, self.root_dir)
|
||||
mtime, _ = get_mtime_and_size(path_info, self.repo.tree)
|
||||
inode = get_inode(path_info)
|
||||
relative_path = relpath(path_info, self.root_dir)
|
||||
|
||||
cmd = "REPLACE INTO {}(path, inode, mtime) " "VALUES (?, ?, ?)".format(
|
||||
self.LINK_STATE_TABLE
|
||||
|
||||
@@ -9,6 +9,7 @@ from dvc.utils import copyfile
|
||||
from dvc.utils import file_md5
|
||||
from dvc.utils import fix_env
|
||||
from dvc.utils import makedirs
|
||||
from dvc.utils import relpath
|
||||
from dvc.utils import to_chunks
|
||||
from dvc.utils import tmp_fname
|
||||
from tests.basic_env import TestDir
|
||||
@@ -139,3 +140,10 @@ def test_tmp_fname():
|
||||
tmp_fname(file_path_info),
|
||||
re.IGNORECASE,
|
||||
)
|
||||
|
||||
|
||||
def test_relpath():
|
||||
path = "path"
|
||||
path_info = PathInfo(path)
|
||||
|
||||
assert relpath(path) == relpath(path_info)
|
||||
|
||||
Reference in New Issue
Block a user