Add support for Cog SCM

Change-Id: I450e1ce7943fda55edf1cb8016f201ce08cd9251
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5018522
Commit-Queue: Josip Sokcevic <sokcevic@chromium.org>
Reviewed-by: Yiwei Zhang <yiwzhang@google.com>
diff --git a/gclient.py b/gclient.py
index c1d23b4..8ee5bf1 100755
--- a/gclient.py
+++ b/gclient.py
@@ -1574,6 +1574,17 @@
 
 class GitDependency(Dependency):
     """A Dependency object that represents a single git checkout."""
+    _is_env_cog = None
+
+    @staticmethod
+    def _IsCog():
+        """Returns true if the env is cog"""
+        if GitDependency._is_env_cog is None:
+            GitDependency._is_env_cog = os.getcwd().startswith(
+                '/google/cog/cloud')
+
+        return GitDependency._is_env_cog
+
     @staticmethod
     def updateProtocol(url, protocol):
         """Updates given URL's protocol"""
@@ -1592,6 +1603,9 @@
     #override
     def CreateSCM(self, out_cb=None):
         """Create a Wrapper instance suitable for handling this git dependency."""
+        if self._IsCog():
+            return gclient_scm.CogWrapper()
+
         return gclient_scm.GitWrapper(self.url,
                                       self.root.root_dir,
                                       self.name,