From 11b4c730813a10df8155555ece6c93e4b33a93b3 Mon Sep 17 00:00:00 2001 From: Jonathan Lee Date: Thu, 6 Apr 2023 14:42:01 -0400 Subject: [PATCH] [wpt-lint] Handle `FileNotFoundError` when `git` is not found `tools.lint.lint` is unimportable when `git` does not exist in the `PATH`: ``` File "C:\b\s\w\ir\third_party\blink\tools\blinkpy\tool\commands\lint_wpt.py", line 16, in from tools.lint import lint as wptlint File "C:\b\s\w\ir\third_party\wpt_tools\wpt\tools\lint\__init__.py", line 1, in from . import lint # noqa: F401 File "C:\b\s\w\ir\third_party\wpt_tools\wpt\tools\lint\lint.py", line 1135, in subprocess.check_output(["git", "--version"]) ... File "C:\b\s\w\ir\.task_template_vpython_cache\vpython\store\cpython-e6tenrlsesftvg6k08ajgkk7b4\contents\bin\Lib\subprocess.py", line 1311, in _execute_child hp, ht, pid, tid = _winapi.CreateProcess(executable, args, FileNotFoundError: [WinError 2] The system cannot find the file specified ``` --- tools/lint/lint.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/lint/lint.py b/tools/lint/lint.py index f51e451a4d123a..89ecee8035c71e 100644 --- a/tools/lint/lint.py +++ b/tools/lint/lint.py @@ -1134,7 +1134,7 @@ def process_errors(errors): try: subprocess.check_output(["git", "--version"]) all_paths_lints += [check_git_ignore] -except subprocess.CalledProcessError: +except (subprocess.CalledProcessError, FileNotFoundError): print('No git present; skipping .gitignore lint.') if __name__ == "__main__":