git_cache.py: Don't bootstrap from Google storage for unrecognized repos.

Also - Turn on GC for the unrecognized repos.

BUG=skia:6241
TEST=local
  git_cache.py populate with chromium and non-chromium repo.

Change-Id: I100d3665e317b29c5b3f69b49c165ce88cd019d6
Reviewed-on: https://chromium-review.googlesource.com/455979
Commit-Queue: Ryan Tseng <hinoka@chromium.org>
Reviewed-by: Aaron Gable <agable@chromium.org>
diff --git a/git_cache.py b/git_cache.py
index bae45e7..20b8445 100755
--- a/git_cache.py
+++ b/git_cache.py
@@ -225,10 +225,13 @@
 
   @property
   def bootstrap_bucket(self):
-    if 'chrome-internal' in self.url:
-      return 'chrome-git-cache'
-    else:
+    u = urlparse.urlparse(self.url)
+    if u.netloc == 'chromium.googlesource.com':
       return 'chromium-git-cache'
+    elif u.netloc == 'chrome-internal.googlesource.com':
+      return 'chrome-git-cache'
+    # Not recognized.
+    return None
 
   @classmethod
   def FromPath(cls, path):
@@ -304,7 +307,8 @@
     # Don't combine pack files into one big pack file.  It's really slow for
     # repositories, and there's no way to track progress and make sure it's
     # not stuck.
-    self.RunGit(['config', 'gc.autopacklimit', '0'], cwd=cwd)
+    if self.supported_project():
+      self.RunGit(['config', 'gc.autopacklimit', '0'], cwd=cwd)
 
     # Allocate more RAM for cache-ing delta chains, for better performance
     # of "Resolving deltas".
@@ -325,6 +329,8 @@
     More apt-ly named bootstrap_repo_from_cloud_if_possible_else_do_nothing().
     """
 
+    if not self.bootstrap_bucket:
+      return False
     python_fallback = False
     if (sys.platform.startswith('win') and
         not gclient_utils.FindExecutable('7z')):
@@ -393,6 +399,13 @@
   def exists(self):
     return os.path.isfile(os.path.join(self.mirror_path, 'config'))
 
+  def supported_project(self):
+    """Returns true if this repo is known to have a bootstrap zip file."""
+    u = urlparse.urlparse(self.url)
+    return u.netloc in [
+        'chromium.googlesource.com',
+        'chrome-internal.googlesource.com']
+
   def _preserve_fetchspec(self):
     """Read and preserve remote.origin.fetch from an existing mirror.
 
@@ -433,8 +446,11 @@
       if bootstrapped:
         # Bootstrap succeeded; delete previous cache, if any.
         gclient_utils.rmtree(self.mirror_path)
-      elif not self.exists():
-        # Bootstrap failed, no previous cache; start with a bare git dir.
+      elif not self.exists() or not self.supported_project():
+        # Bootstrap failed due to either
+        # 1. No previous cache
+        # 2. Project doesn't have a bootstrap zip file
+        # Start with a bare git dir.
         self.RunGit(['init', '--bare'], cwd=tempdir)
       else:
         # Bootstrap failed, previous cache exists; warn and continue.