Coverage for src/rhiza_hooks/_repo.py: 100%

9 statements  

« prev     ^ index     » next       coverage.py v7.14.1, created at 2026-07-30 04:36 +0000

1#!/usr/bin/env python3 

2"""Shared internal helpers for rhiza hooks.""" 

3 

4from __future__ import annotations 

5 

6from pathlib import Path 

7 

8 

9def find_repo_root() -> Path: 

10 """Find the repository root directory. 

11 

12 Walks up from the current working directory looking for a ``.git`` entry. 

13 

14 Returns: 

15 Path to the nearest ancestor containing ``.git``, or the current 

16 working directory if none is found. 

17 """ 

18 current = Path.cwd() 

19 while current != current.parent: 

20 if (current / ".git").exists(): 

21 return current 

22 current = current.parent 

23 return Path.cwd()