Skip to content

Commit f514ab2

Browse files
committed
Get absolute git path
1 parent add4167 commit f514ab2

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

codespell_lib/_codespell.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1102,6 +1102,14 @@ def flatten_clean_comma_separated_arguments(
11021102
]
11031103

11041104

1105+
def get_git_executable_path() -> str:
1106+
# Find the full path to the git executable
1107+
git_path = shutil.which("git")
1108+
if git_path is None:
1109+
raise FileNotFoundError("Git executable not found in PATH")
1110+
return git_path
1111+
1112+
11051113
def get_git_tracked_files(
11061114
root: str, files: Iterable[str], glob_match: GlobMatch, check_hidden: bool
11071115
) -> Iterable[str]:
@@ -1122,9 +1130,11 @@ def get_git_tracked_files(
11221130
if not check_hidden:
11231131
exclude_patterns.append(":(exclude)**/.*")
11241132

1133+
git_executable = get_git_executable_path()
1134+
11251135
try:
11261136
result = subprocess.run(
1127-
["git", "ls-files", *file_args, *exclude_patterns],
1137+
[git_executable, "ls-files", *file_args, *exclude_patterns],
11281138
cwd=root,
11291139
capture_output=True,
11301140
check=True,

0 commit comments

Comments
 (0)