Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 1 addition & 12 deletions dvc/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,18 +112,7 @@ def __init__(self, path):


class NotDvcRepoError(DvcException):
"""Thrown if a directory is not a DVC repo.

Args:
root (str): path to the directory.
"""

def __init__(self, root):
msg = (
"you are not inside of a DVC repository "
"(checked up to mount point '{}')"
)
super().__init__(msg.format(root))
"""Thrown if a directory is not a DVC repo"""


class DvcParserError(DvcException):
Expand Down
23 changes: 14 additions & 9 deletions dvc/repo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,19 +129,24 @@ def __repr__(self):

@classmethod
def find_root(cls, root=None):
if root is None:
root = os.getcwd()
else:
root = os.path.abspath(os.path.realpath(root))
root_dir = os.path.realpath(root or os.curdir)

if not os.path.isdir(root_dir):
raise NotDvcRepoError("directory '{}' does not exist".format(root))

while True:
dvc_dir = os.path.join(root, cls.DVC_DIR)
dvc_dir = os.path.join(root_dir, cls.DVC_DIR)
if os.path.isdir(dvc_dir):
return root
if os.path.ismount(root):
return root_dir
if os.path.ismount(root_dir):
break
root = os.path.dirname(root)
raise NotDvcRepoError(root)
root_dir = os.path.dirname(root_dir)

message = (
"you are not inside of a DVC repository "
"(checked up to mount point '{}')"
).format(root_dir)
raise NotDvcRepoError(message)

@classmethod
def find_dvc_dir(cls, root=None):
Expand Down