From f8966234044871b0bd46383e5beff2a87967edc7 Mon Sep 17 00:00:00 2001 From: Brad Davis Date: Fri, 15 Feb 2019 14:30:54 -0800 Subject: [PATCH] Fix prebuild crash if can't find git binary (such as when running under Android Studio) --- prebuild.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/prebuild.py b/prebuild.py index 060e1fd3b0..5325ca34bc 100644 --- a/prebuild.py +++ b/prebuild.py @@ -58,6 +58,9 @@ logging.setLoggerClass(TrackableLogger) logger = logging.getLogger('prebuild') def headSha(): + if shutil.which('git') is None: + logger.warn("Unable to find git executable, can't caclulate commit ID") + return '0xDEADBEEF' repo_dir = os.path.dirname(os.path.abspath(__file__)) git = subprocess.Popen( 'git rev-parse --short HEAD', @@ -67,7 +70,7 @@ def headSha(): stdout, _ = git.communicate() sha = stdout.split('\n')[0] if not sha: - raise RuntimeError("couldn't find git sha") + raise RuntimeError("couldn't find git sha for repository {}".format(repo_dir)) return sha @contextmanager