summaryrefslogtreecommitdiff
path: root/cbuildbot/repository.py
diff options
context:
space:
mode:
authorGabe Black <gabeblack@chromium.org>2014-10-30 14:01:17 -0700
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2014-10-31 19:22:09 +0000
commit4204654f75dccef2c31d858f716283b2e3be2f23 (patch)
treec767a7c655f6de06417b6d62ad0569897cfa1b95 /cbuildbot/repository.py
parent663fecc210135b944ae987f683bab88c7501787f (diff)
downloadchromite-4204654f75dccef2c31d858f716283b2e3be2f23.tar.gz
git: Expose the --branch and --single-branch options in CloneGitRepo.
If you're only using a particular branch, it can speed up the clone significantly to limit it to that branch. BUG=chromium:399356 TEST=Ran run_tests. Change-Id: I459a93856c0b53b414c3ad3b382e78f7a6eadfc6 Reviewed-on: https://chromium-review.googlesource.com/226772 Reviewed-by: Gabe Black <gabeblack@chromium.org> Commit-Queue: Gabe Black <gabeblack@chromium.org> Tested-by: Gabe Black <gabeblack@chromium.org>
Diffstat (limited to 'cbuildbot/repository.py')
-rw-r--r--cbuildbot/repository.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/cbuildbot/repository.py b/cbuildbot/repository.py
index f63908cd4..331c74f8b 100644
--- a/cbuildbot/repository.py
+++ b/cbuildbot/repository.py
@@ -42,7 +42,7 @@ def IsInternalRepoCheckout(root):
def CloneGitRepo(working_dir, repo_url, reference=None, bare=False,
- mirror=False, depth=None):
+ mirror=False, depth=None, branch=None, single_branch=False):
"""Clone given git repo
Args:
@@ -56,6 +56,8 @@ def CloneGitRepo(working_dir, repo_url, reference=None, bare=False,
depth: If given, do a shallow clone limiting the objects pulled to just
that # of revs of history. This option is mutually exclusive to
reference.
+ branch: If given, clone the given branch from the parent repository.
+ single_branch: Clone only one the requested branch.
"""
osutils.SafeMakedirs(working_dir)
cmd = ['clone', repo_url, working_dir]
@@ -70,6 +72,10 @@ def CloneGitRepo(working_dir, repo_url, reference=None, bare=False,
cmd += ['--mirror']
if depth:
cmd += ['--depth', str(int(depth))]
+ if branch:
+ cmd += ['--branch', branch]
+ if single_branch:
+ cmd += ['--single-branch']
git.RunGit(working_dir, cmd)