Skip to content

Commit 020870f

Browse files
authored
Handle FileNotFoundError and OSError in _exec (v3.0.0) (#126)
1 parent 50b5618 commit 020870f

File tree

1 file changed

+5
-0
lines changed
  • setuptools_git_versioning

1 file changed

+5
-0
lines changed

setuptools_git_versioning/git.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ def _exec(*cmd: str, root: str | os.PathLike | None = None) -> list[str]:
1919
stdout = subprocess.check_output(cmd, text=True, cwd=root) # noqa: S603
2020
except subprocess.CalledProcessError as e:
2121
stdout = e.output
22+
except (FileNotFoundError, OSError) as e:
23+
# Handle case where git executable is not found
24+
# FileNotFoundError on Unix, OSError on some other systems
25+
log.log(DEBUG, "Command not found: %r", e)
26+
stdout = ""
2227
lines = stdout.splitlines()
2328
return [line.rstrip() for line in lines if line.rstrip()]
2429

0 commit comments

Comments
 (0)