mirror of
https://gerrit.googlesource.com/git-repo
synced 2024-12-21 07:16:21 +00:00
sync: Added --filter=blob:none (and no-depth) wduring git clone of superproject.
Tested the code with the following commands. $ ./run_tests -v tests/test_git_superproject.py $ ./run_tests -v Tested the sync code by copying all the repo changes into my Android AOSP checkout and doing a repo sync --use-superproject twice. .../WORKING_DIRECTORY$ repo sync --use-superproject Bug: https://crbug.com/gerrit/13709 Bug: https://crbug.com/gerrit/13707 Tested-by: Raman Tenneti <rtenneti@google.com> Change-Id: Ieea31445ca89ba1d217e779ec7a7a2ebe81ac518
This commit is contained in:
parent
db3128f2ec
commit
9e7875315f
@ -27,7 +27,6 @@ import sys
|
||||
|
||||
from error import GitError
|
||||
from git_command import GitCommand
|
||||
import platform_utils
|
||||
|
||||
|
||||
class Superproject(object):
|
||||
@ -63,7 +62,8 @@ class Superproject(object):
|
||||
Returns:
|
||||
True if 'git clone <url> <branch>' is successful, or False.
|
||||
"""
|
||||
cmd = ['clone', url, '--depth', '1']
|
||||
os.mkdir(self._superproject_path)
|
||||
cmd = ['clone', url, '--filter', 'blob:none']
|
||||
if branch:
|
||||
cmd += ['--branch', branch]
|
||||
p = GitCommand(None,
|
||||
@ -80,6 +80,28 @@ class Superproject(object):
|
||||
return False
|
||||
return True
|
||||
|
||||
def _Pull(self):
|
||||
"""Do a 'git pull' to to fetch the latest content.
|
||||
|
||||
Returns:
|
||||
True if 'git pull <branch>' is successful, or False.
|
||||
"""
|
||||
git_dir = os.path.join(self._superproject_path, 'superproject')
|
||||
if not os.path.exists(git_dir):
|
||||
raise GitError('git pull. Missing drectory: %s' % git_dir)
|
||||
cmd = ['pull']
|
||||
p = GitCommand(None,
|
||||
cmd,
|
||||
cwd=git_dir,
|
||||
capture_stdout=True,
|
||||
capture_stderr=True)
|
||||
retval = p.Wait()
|
||||
if retval:
|
||||
print('repo: error: git pull call failed with return code: %r, stderr: %r' %
|
||||
(retval, p.stderr), file=sys.stderr)
|
||||
return False
|
||||
return True
|
||||
|
||||
def _LsTree(self):
|
||||
"""Returns the data from 'git ls-tree -r HEAD'.
|
||||
|
||||
@ -121,10 +143,9 @@ class Superproject(object):
|
||||
if not url:
|
||||
raise ValueError('url argument is not supplied.')
|
||||
if os.path.exists(self._superproject_path):
|
||||
platform_utils.rmtree(self._superproject_path)
|
||||
os.mkdir(self._superproject_path)
|
||||
|
||||
# TODO(rtenneti): we shouldn't be cloning the repo from scratch every time.
|
||||
if not self._Pull():
|
||||
raise GitError('git pull failed for url: %s' % url)
|
||||
else:
|
||||
if not self._Clone(url, branch):
|
||||
raise GitError('git clone failed for url: %s' % url)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user