Skip to content

Commit

Permalink
source_info: add within_git_repo method
Browse files Browse the repository at this point in the history
Check for git files and folders, including those of parents.

Signed-off-by:  Eric Callahan <[email protected]>
  • Loading branch information
Arksine committed Jun 20, 2023
1 parent 86af3a4 commit 35396a5
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion moonraker/utils/source_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 35396a5

Please sign in to comment.