[git_cl] Don't check .gitcookies when running on LUCI.

This CL basically replaces "skip if is_gce" with "skip if default auth method
is not gitcookies".

This presumable makes 'git cl' work on LUCI in a consistent manner. Before, it
worked only if the LUCI bot happened to also be GCE bot.

R=tandrii@chromium.org
BUG=891755

Change-Id: I2caa219a4082438a5e026e728bfb62f46a0c80fd
Reviewed-on: https://chromium-review.googlesource.com/c/1260053
Commit-Queue: Vadim Shtayura <vadimsh@chromium.org>
Reviewed-by: Andrii Shyshkalov <tandrii@chromium.org>
diff --git a/gerrit_util.py b/gerrit_util.py
index b81f7b5..e8e9561 100644
--- a/gerrit_util.py
+++ b/gerrit_util.py
@@ -104,9 +104,27 @@
   Expected case for developer workstations.
   """
 
+  _EMPTY = object()
+
   def __init__(self):
-    self.netrc = self._get_netrc()
-    self.gitcookies = self._get_gitcookies()
+    # Credentials will be loaded lazily on first use. This ensures Authenticator
+    # get() can always construct an authenticator, even if something is broken.
+    # This allows 'creds-check' to proceed to actually checking creds later,
+    # rigorously (instead of blowing up with a cryptic error if they are wrong).
+    self._netrc = self._EMPTY
+    self._gitcookies = self._EMPTY
+
+  @property
+  def netrc(self):
+    if self._netrc is self._EMPTY:
+      self._netrc = self._get_netrc()
+    return self._netrc
+
+  @property
+  def gitcookies(self):
+    if self._gitcookies is self._EMPTY:
+      self._gitcookies = self._get_gitcookies()
+    return self._gitcookies
 
   @classmethod
   def get_new_password_url(cls, host):