Allow for git worktree when computing clangtidy scm root (#123060)

When you make a git worktree, the .git "folder" in the worktree
is not a directory, it's a file pointing at the actual .git directory.

Signed-off-by: Edward Z. Yang <ezyang@meta.com>
Pull Request resolved: https://github.com/pytorch/pytorch/pull/123060
Approved by: https://github.com/albanD
This commit is contained in:
Edward Z. Yang
2024-03-31 20:22:03 +01:00
committed by PyTorch MergeBot
parent 0fd072bf90
commit 0d3a771f7b

View File

@ -18,7 +18,7 @@ from typing import Any, List, NamedTuple, Optional, Pattern
def scm_root() -> str:
path = os.path.abspath(os.getcwd())
while True:
if os.path.isdir(os.path.join(path, ".git")):
if os.path.exists(os.path.join(path, ".git")):
return path
if os.path.isdir(os.path.join(path, ".hg")):
return path