[patchew-devel] [PATCH] cli: clone recursively only for tester

  • From: Fam Zheng <famz@xxxxxxxxxx>
  • To: patchew-devel@xxxxxxxxxxxxx
  • Date: Thu, 1 Mar 2018 10:50:34 +0800

Both tester and apply (applier mode) subcommands call git_clone_repo.
"--recursive" option was added so that repos that contain submodules
will likely just work with all the submodules present (although that can
be optimized too, to save time and bandwidth), but it is not necessary
for appliers and can significantly slow down the process because the
submodule repos are not cached.

Signed-off-by: Fam Zheng <famz@xxxxxxxxxx>
---
 patchew-cli | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/patchew-cli b/patchew-cli
index eb8b91c..52329e1 100755
--- a/patchew-cli
+++ b/patchew-cli
@@ -29,7 +29,7 @@ COOKIE_FILENAME = os.path.expanduser("~/.patchew.cookie")
 class APIError(Exception):
     pass
 
-def git_clone_repo(clone, remote, head, logf, checkout=True):
+def git_clone_repo(clone, remote, head, logf, checkout=True, recursive=False):
     cache_repo = os.path.join(os.path.expanduser("~/.cache/patchew-git-cache"),
                               "".join([x for x in remote if x.isalnum()]) + 
"-" + \
                                       
hashlib.sha1(remote.encode("utf-8")).hexdigest())
@@ -46,8 +46,11 @@ def git_clone_repo(clone, remote, head, logf, checkout=True):
     subprocess.check_call(["git", "remote", "add", "-f", "--mirror=fetch",
                           remote_name, remote], cwd=cache_repo,
                           stdout=logf, stderr=logf)
-    subprocess.check_call(["git", "clone", "-q", "--recursive", cache_repo, 
clone],
-                          stderr=logf, stdout=logf)
+    clone_cmd = ["git", "clone", "-q"]
+    if recursive:
+        clone_cmd += ["--recursive"]
+    clone_cmd += [cache_repo, clone]
+    subprocess.check_call(clone_cmd, stderr=logf, stdout=logf)
     if checkout:
         subprocess.check_call(["git", "checkout", head, "-b", "test"],
                               stderr=logf, stdout=logf,
@@ -510,7 +513,7 @@ class TesterCommand(SubCommand):
         is_timeout = False
         try:
             clone = os.path.join(wd, "src")
-            git_clone_repo(clone, r["repo"], r["head"], logf)
+            git_clone_repo(clone, r["repo"], r["head"], logf, True)
             base = r["base"]
             if base:
                 subprocess.check_call(["git", "branch", "base", base],
-- 
2.14.3


Other related posts: