Last active
August 5, 2022 09:24
-
-
Save ivsanro1/d58d095ce582710dc8c68f0550d9bdd1 to your computer and use it in GitHub Desktop.
Simple but useful utility to get the root of the current project (has to be a git project)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import git | |
| import os | |
| from pathlib import Path | |
| def get_root() -> Path: | |
| return Path(git.Repo(os.getcwd(), search_parent_directories=True).working_dir) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment