repo_utils: clone entire branch if commit is specified
authorJosh Durgin <jdurgin@redhat.com>
Tue, 2 Feb 2021 19:48:47 +0000 (14:48 -0500)
committerJosh Durgin <jdurgin@redhat.com>
Tue, 2 Feb 2021 19:54:41 +0000 (14:54 -0500)
If the commit is not the head of the branch, we need more history to be
able to check it out.

Signed-off-by: Josh Durgin <jdurgin@redhat.com>
teuthology/repo_utils.py

index c673fd1eb6eaf7346a2e0df0b99ce1a1b41ee5e6..582ff7999373f20a33b6a52e4f3095465ce03234 100644 (file)
@@ -91,7 +91,7 @@ def enforce_repo_state(repo_url, dest_path, branch, commit=None, remove_on_error
     repo_reset = os.path.join(dest_path, '.fetched_and_reset')
     try:
         if not os.path.isdir(dest_path):
-            clone_repo(repo_url, dest_path, branch)
+            clone_repo(repo_url, dest_path, branch, shallow=commit is None)
         elif not commit and not is_fresh(sentinel):
             set_remote(dest_path, repo_url)
             fetch_branch(dest_path, branch)
@@ -127,7 +127,7 @@ def clone_repo(repo_url, dest_path, branch, shallow=True):
     if branch.startswith('refs/'):
         clone_repo_ref(repo_url, dest_path, branch)
         return
-    args = ['git', 'clone']
+    args = ['git', 'clone', '--single-branch']
     if shallow:
         args.extend(['--depth', '1'])
     args.extend(['--branch', branch, repo_url, dest_path])