cbuildbot_launch: If repo cleanup fails, wipe buildroot.

The is the same logic used in the Sync stages, except for being a bit
more straight forward, and triggering on any exception. This does NOT
preserve cbuildbot_logs, trybot markers or other files that aren't
relevent on the builders.

BUG=chromium:722619
TEST=Unittests + local builds.

Change-Id: I0cdee84aac3317c4faa9996b2f3c594983189587
Reviewed-on: https://chromium-review.googlesource.com/508853
Tested-by: Don Garrett <dgarrett@chromium.org>
Reviewed-by: Ningning Xia <nxia@chromium.org>
Commit-Queue: Don Garrett <dgarrett@chromium.org>
diff --git a/scripts/cbuildbot_launch.py b/scripts/cbuildbot_launch.py
index e0ebcb0..0a77049 100644
--- a/scripts/cbuildbot_launch.py
+++ b/scripts/cbuildbot_launch.py
@@ -157,7 +157,13 @@
   repo = repository.RepoRepository(manifest_url, buildroot,
                                    branch=branchname,
                                    git_cache_dir=git_cache_dir)
-  repo.BuildRootGitCleanup(prune_all=True)
+  try:
+    # If there is any failure doing the cleanup, wipe everything.
+    repo.BuildRootGitCleanup(prune_all=True)
+  except Exception:
+    logging.info('Checkout cleanup failed, wiping buildroot:', exc_info=True)
+    repository.ClearBuildRoot(buildroot)
+
   repo.Sync(detach=True)