def what(dir: Optional[str]) -> Optional[RepoSpec]:
path = findRoot(dir)
if path is None:
d = Path(dir) if dir is not None else Path.cwd()
raise RuntimeError(f"Not a got repository: {d.resolve()}")
# If any clone has this exact path already, return it
clone = Clone.load(path = str(path))
if clone is not None:
return clone.repospec
# If not, try resolving each path to find a match
for clone in Clone.loadAll():
if clone.path.resolve() == path:
return clone.repospec
# Shouldn't be able to get here
d = Path(dir) if dir is not None else Path.cwd()
raise RuntimeError(f"Not a got repository: {d.resolve()}")
评论列表
文章目录