MCPcopy
hub / github.com/GitGuardian/ggshield / _get_git_path

Function _get_git_path

ggshield/utils/git_shell.py:72–91  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

70
71@lru_cache(None)
72def _get_git_path() -> str:
73 git_path = which("git")
74
75 if git_path is None:
76 raise GitExecutableNotFound("unable to find git executable in PATH/PATHEXT")
77
78 # lower()ing these would provide additional coverage on case-
79 # insensitive filesystems but detection is problematic
80 git_path = os.path.abspath(git_path)
81 cwd = os.getcwd()
82 path_env = [
83 os.path.abspath(p) for p in os.environ.get("PATH", "").split(os.pathsep)
84 ]
85
86 # git was found - ignore git in cwd if cwd not in PATH
87 if cwd == os.path.dirname(git_path) and cwd not in path_env:
88 raise GitExecutableNotFound("rejecting git executable in CWD not in PATH")
89
90 logger.debug("Found git at %s", git_path)
91 return git_path
92
93
94@lru_cache(None)

Callers 2

is_git_availableFunction · 0.85
gitFunction · 0.85

Calls 2

getMethod · 0.80

Tested by

no test coverage detected