From 4fd38ecc3ae6ce004b59ffe6545918495080e165 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Tue, 5 Jun 2012 07:55:07 -0700 Subject: [PATCH] Detect git is not installed Fix detection for Git not being in $PATH during the initial run of `repo init` in a new directory. Change-Id: I2b1fcce1fb8afc47271f5c3bd2a28369009b2fb7 --- repo | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/repo b/repo index 860a15d5..05d4455d 100755 --- a/repo +++ b/repo @@ -28,7 +28,7 @@ if __name__ == '__main__': del magic # increment this whenever we make important changes to this script -VERSION = (1, 16) +VERSION = (1, 17) # increment this if the MAINTAINER_KEYS block is modified KEYRING_VERSION = (1,0) @@ -220,7 +220,17 @@ def _Init(args): def _CheckGitVersion(): cmd = [GIT, '--version'] - proc = subprocess.Popen(cmd, stdout=subprocess.PIPE) + try: + proc = subprocess.Popen(cmd, stdout=subprocess.PIPE) + except OSError, e: + print >>sys.stderr + print >>sys.stderr, "fatal: '%s' is not available" % GIT + print >>sys.stderr, 'fatal: %s' % e + print >>sys.stderr + print >>sys.stderr, 'Please make sure %s is installed'\ + ' and in your path.' % GIT + raise CloneFailure() + ver_str = proc.stdout.read().strip() proc.stdout.close() proc.wait()