Fix cleanup function to be a bit more robust.

Example failure:
  https://uberchromegw/i/chromeos/builders/whirlwind%20paladin/builds/3673

TBR=akeshet
BUG=chromium:55250
TEST=unit test

Change-Id: I079b11ef90e05e23323010fd92e6527885adacbd
Reviewed-on: https://chromium-review.googlesource.com/311783
Tested-by: David James <davidjames@chromium.org>
Reviewed-by: Fang Deng <fdeng@chromium.org>
diff --git a/cbuildbot/commands.py b/cbuildbot/commands.py
index a2bc1c9..5202944 100644
--- a/cbuildbot/commands.py
+++ b/cbuildbot/commands.py
@@ -186,7 +186,7 @@
         logging.warning('\n%s', result.error)
 
         # If there's no repository corruption, just delete the index.
-        corrupted = git.IsGitRepositoryCorrupted(cwd)
+        corrupted = git.IsGitRepositoryCorrupted(repo_git_store)
         lock.write_lock()
         logging.warning('Deleting %s because %s failed', cwd, result.cmd)
         osutils.RmDir(cwd, ignore_missing=True)