Bug 1493510 [wpt PR 13177] - Check if platform is Windows before catching WindowsError, a=testonly

Automatic update from web-platform-testsCheck if platform is Windows before catching WindowsError

Check if the platform is Windows and the error is a WindowsError before
trying to run git.bat, as WindowsError is not defined in non-Windows.

Closes https://github.com/web-platform-tests/wpt/issues/12693

--

wpt-commits: 82d852bda1e08948858389c17402fa0571bc2584
wpt-pr: 13177
This commit is contained in:
Ahilya Sinha 2018-09-26 10:47:19 +00:00 committed by moz-wptsync-bot
parent 51766e943f
commit 7da39973f5

View File

@ -1,5 +1,6 @@
import os
import subprocess
import platform
from .sourcefile import SourceFile
@ -16,9 +17,12 @@ class Git(object):
full_cmd = ["git", cmd] + list(args)
try:
return subprocess.check_output(full_cmd, cwd=repo_path, stderr=subprocess.STDOUT)
except WindowsError:
full_cmd[0] = "git.bat"
return subprocess.check_output(full_cmd, cwd=repo_path, stderr=subprocess.STDOUT)
except Exception as e:
if platform.uname()[0] == "Windows" and isinstance(e, WindowsError):
full_cmd[0] = "git.bat"
return subprocess.check_output(full_cmd, cwd=repo_path, stderr=subprocess.STDOUT)
else:
raise
return git
@classmethod