This commit is contained in:
sankalp committed 2026-06-16 14:45:55 +05:45
1 parent 51ede1a7da
commit 869aa37f0c
4 files changed
+16 -5

No files matched your search

+9
View File
@@ -142,6 +142,15 @@ def configure_logger(
return logger
def get_git_root(cwd: Optional[Path] = None) -> Optional[Path]:
"""Return the root directory of the current git repository, or None."""
try:
output = run_git_command(["git", "rev-parse", "--show-toplevel"], cwd=cwd)
return Path(output) if output else None
except (subprocess.CalledProcessError, FileNotFoundError):
return None
def run_git_command(
args: list[str],
check: bool = True,