Skip to content

Commit 225a8c2

Browse files
committed
refactor(git): make find_git_project_root return None if it's not a git project
pathlib returns Path('.') if empty is passed
1 parent 74654df commit 225a8c2

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

commitizen/git.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ def get_all_tags() -> Optional[List[str]]:
5858
return [tag.strip() for tag in c.out.split("\n") if tag.strip()]
5959

6060

61-
def find_git_project_root() -> Path:
61+
def find_git_project_root() -> Optional[Path]:
6262
c = cmd.run("git rev-parse --show-toplevel")
63-
return Path(c.out.strip())
63+
if not c.err:
64+
return Path(c.out.strip())
65+
return None

0 commit comments

Comments
 (0)