From 4cdd7f7d86f682c481480c75032cd9b47eface66 Mon Sep 17 00:00:00 2001
From: David Ostrovsky <david@ostrovsky.org>
Date: Sun, 3 Nov 2019 13:26:35 +0100
Subject: [PATCH] Bazel: Special handling for plugins not under git control

To be compatible with the shell script, ignore "not a git repository
error" and report "unknown" version.

Change-Id: Ifa5dafea63743e6e09958f4283231c3eb7e45afe
---
 tools/workspace_status.py | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/tools/workspace_status.py b/tools/workspace_status.py
index eef864eee3..86df519ed5 100644
--- a/tools/workspace_status.py
+++ b/tools/workspace_status.py
@@ -29,8 +29,8 @@ def revision(directory, parent):
         print('could not invoke git: %s' % err, file=sys.stderr)
         sys.exit(1)
     except subprocess.CalledProcessError as err:
-        print('error using git: %s' % err, file=sys.stderr)
-        sys.exit(1)
+        # ignore "not a git repository error" to report unknown version
+        return None
     finally:
         os.chdir(parent)
 
@@ -40,5 +40,5 @@ for d in os.listdir(os.path.join(ROOT, 'plugins')):
     p = os.path.join('plugins', d)
     if os.path.isdir(p):
         v = revision(p, ROOT)
-        if v:
-            print('STABLE_BUILD_%s_LABEL %s' % (os.path.basename(p).upper(), v))
+        print('STABLE_BUILD_%s_LABEL %s' % (os.path.basename(p).upper(),
+                                            v if v else 'unknown'))