skylab_utils: Do a shallow clone to save time.

BUG=chromium:842754
TEST=manual

Change-Id: I92f7dedda150b2fe733d06d5a762d8458c9902fa
Reviewed-on: https://chromium-review.googlesource.com/1112621
Commit-Ready: Prathmesh Prabhu <[email protected]>
Tested-by: Prathmesh Prabhu <[email protected]>
Reviewed-by: Jacob Kopczynski <[email protected]>
diff --git a/cli/skylab_utils.py b/cli/skylab_utils.py
index 60a3dfd..0b5de24 100644
--- a/cli/skylab_utils.py
+++ b/cli/skylab_utils.py
@@ -127,7 +127,7 @@
             self.git_repo.pull()
         else:
             logging.info('No inventory repo was found, start cloning.')
-            self.git_repo.clone()
+            self.git_repo.clone(shallow=True)
 
 
     def get_data_dir(self, data_subdir='skylab'):
diff --git a/client/common_lib/revision_control.py b/client/common_lib/revision_control.py
index d8d8dec..3d5c570 100644
--- a/client/common_lib/revision_control.py
+++ b/client/common_lib/revision_control.py
@@ -158,7 +158,7 @@
         return rv
 
 
-    def clone(self, remote_branch=None):
+    def clone(self, remote_branch=None, shallow=False):
         """
         Clones a repo using giturl and repodir.
 
@@ -168,6 +168,7 @@
 
         @param remote_branch: Specify the remote branch to clone. None if to
                               clone master branch.
+        @param shallow: If True, do a shallow clone.
 
         @raises GitCloneError: if cloning the master repo fails.
         """
@@ -175,6 +176,8 @@
         cmd = 'clone %s %s ' % (self.giturl, self.repodir)
         if remote_branch:
             cmd += '-b %s' % remote_branch
+        if shallow:
+            cmd += '--depth 1'
         abs_work_tree = self.work_tree
         self.work_tree = None
         try: