]> code.ossystems Code Review - openembedded-core.git/commitdiff
devtool: update-recipe: check if source tree is a git repository
authorPaul Eggleton <paul.eggleton@linux.intel.com>
Mon, 27 Apr 2015 09:53:21 +0000 (10:53 +0100)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Mon, 27 Apr 2015 14:05:40 +0000 (15:05 +0100)
If you've done "devtool add" (or "devtool modify" without -x) then it's
possible that the external source tree is not a git repository, so we
should handle that case here instead of printing a traceback.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
scripts/lib/devtool/standard.py

index a64211211b3868da745becbce19a39c8ae8dda36..94b5e0bdd1178717b9de116d2f5afa8886543a34 100644 (file)
@@ -477,13 +477,19 @@ def update_recipe(args, config, basepath, workspace):
         return updated
 
     srctree = workspace[args.recipename]
-    if mode == 'srcrev':
+
+    # Get HEAD revision
+    try:
         (stdout, _) = bb.process.run('git rev-parse HEAD', cwd=srctree)
-        srcrev = stdout.strip()
-        if len(srcrev) != 40:
-            logger.error('Invalid hash returned by git: %s' % stdout)
-            return 1
+    except bb.process.ExecutionError as err:
+        print('Failed to get HEAD revision in %s: %s' % (srctree, err))
+        return 1
+    srcrev = stdout.strip()
+    if len(srcrev) != 40:
+        logger.error('Invalid hash returned by git: %s' % stdout)
+        return 1
 
+    if mode == 'srcrev':
         logger.info('Updating SRCREV in recipe %s' % os.path.basename(recipefile))
         patchfields = {}
         patchfields['SRCREV'] = srcrev