Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions dunk/dunk.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import functools
import os
import subprocess
import sys
from collections import defaultdict
from difflib import SequenceMatcher
Expand Down Expand Up @@ -32,15 +33,10 @@
# TODO: Use rich pager here?

def find_git_root() -> Path:
cwd = Path.cwd()
if (cwd / ".git").exists():
return Path.cwd()

for directory in cwd.parents:
if (directory / ".git").exists():
return directory

return cwd
return Path(subprocess.check_output(
['git', 'rev-parse', '--show-toplevel'],
stderr=subprocess.DEVNULL,
).decode().strip())


class ContiguousStreak(NamedTuple):
Expand Down