source_info: add within_git_repo method
Check for git files and folders, including those of parents. Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
parent
86af3a42ff
commit
35396a5b2a
|
@ -23,9 +23,19 @@ def source_path() -> pathlib.Path:
|
|||
|
||||
def is_git_repo(src_path: Optional[pathlib.Path] = None) -> bool:
|
||||
if src_path is None:
|
||||
return source_path().joinpath(".git").is_dir()
|
||||
src_path = source_path()
|
||||
return src_path.joinpath(".git").is_dir()
|
||||
|
||||
def within_git_repo(src_path: Optional[pathlib.Path] = None) -> bool:
|
||||
if src_path is None:
|
||||
src_path = source_path()
|
||||
if src_path.joinpath(".git").is_dir():
|
||||
return True
|
||||
for parent in src_path.parents:
|
||||
if parent.joinpath(".git").is_dir():
|
||||
return True
|
||||
return False
|
||||
|
||||
def is_dist_package(src_path: Optional[pathlib.Path] = None) -> bool:
|
||||
if src_path is None:
|
||||
# Check Moonraker's source path
|
||||
|
|
Loading…
Reference in New Issue