from pathlib import Path


def find_git_root_directory(file_path: Path) -> Path:
    """Attempts to find a .git directory, starting to the folder where we run the
    script and moving up the filesystem."""
    path: Path = file_path.parent
    for index in range(5):
        if Path(path, ".git").exists():
            break
        path = path.parent
    return path