Fix for repos with many tags
Ensures all tags are ready before checkout, using `--branch` if possible and an extra pull if that is not available. Also adds `--depth 1` to create shallow clones if the git version is sufficient. Fixes #64.
This commit is contained in:
parent
277df08676
commit
0b5ca25358
1 changed files with 8 additions and 1 deletions
|
@ -417,12 +417,18 @@ def fetch(self):
|
||||||
# If we want a particular branch ask for it.
|
# If we want a particular branch ask for it.
|
||||||
if self.branch:
|
if self.branch:
|
||||||
args.extend(['--branch', self.branch])
|
args.extend(['--branch', self.branch])
|
||||||
|
elif self.tag and self.git_version >= ver('1.8.5.2'):
|
||||||
|
args.extend(['--branch', self.tag])
|
||||||
|
|
||||||
# Try to be efficient if we're using a new enough git.
|
# Try to be efficient if we're using a new enough git.
|
||||||
# This checks out only one branch's history
|
# This checks out only one branch's history
|
||||||
if self.git_version > ver('1.7.10'):
|
if self.git_version > ver('1.7.10'):
|
||||||
args.append('--single-branch')
|
args.append('--single-branch')
|
||||||
|
|
||||||
|
# Yet more efficiency, only download a 1-commit deep tree
|
||||||
|
if self.git_version >= ver('1.7.1'):
|
||||||
|
args.extend(['--depth','1'])
|
||||||
|
|
||||||
args.append(self.url)
|
args.append(self.url)
|
||||||
self.git(*args)
|
self.git(*args)
|
||||||
self.stage.chdir_to_source()
|
self.stage.chdir_to_source()
|
||||||
|
@ -430,7 +436,8 @@ def fetch(self):
|
||||||
# For tags, be conservative and check them out AFTER
|
# For tags, be conservative and check them out AFTER
|
||||||
# cloning. Later git versions can do this with clone
|
# cloning. Later git versions can do this with clone
|
||||||
# --branch, but older ones fail.
|
# --branch, but older ones fail.
|
||||||
if self.tag:
|
if self.tag and self.git_version < ver('1.8.5.2'):
|
||||||
|
self.git('pull', '--tags')
|
||||||
self.git('checkout', self.tag)
|
self.git('checkout', self.tag)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue