MCPcopy
hub / github.com/zju3dv/4K4D / find_vcs_root

Function find_vcs_root

easyvolcap/engine/path.py:81–97  ·  view source on GitHub ↗

Finds the root directory (including itself) of specified markers. Args: path (str): Path of directory or file. markers (list[str], optional): List of file or directory names. Returns: The directory contained one of the markers or None if not found.

(path, markers=('.git', ))

Source from the content-addressed store, hash-verified

79
80
81def find_vcs_root(path, markers=('.git', )):
82 """Finds the root directory (including itself) of specified markers.
83 Args:
84 path (str): Path of directory or file.
85 markers (list[str], optional): List of file or directory names.
86 Returns:
87 The directory contained one of the markers or None if not found.
88 """
89 if osp.isfile(path):
90 path = osp.dirname(path)
91
92 prev, cur = None, osp.abspath(osp.expanduser(path))
93 while cur != prev:
94 if any(osp.exists(osp.join(cur, marker)) for marker in markers):
95 return cur
96 prev, cur = cur, osp.split(cur)[0]
97 return None

Callers

nothing calls this directly

Calls 3

splitMethod · 0.80
isfileMethod · 0.45
existsMethod · 0.45

Tested by

no test coverage detected