mirror of
https://gerrit.googlesource.com/git-repo
synced 2025-01-02 16:14:25 +00:00
Add a --depth option to repo init.
Change-Id: Id30fb4a85f4f8a1847420b0b51a86060041eb5bf
This commit is contained in:
parent
d6c93a28ca
commit
30d452905f
@ -1370,6 +1370,13 @@ class Project(object):
|
|||||||
ref_dir = None
|
ref_dir = None
|
||||||
|
|
||||||
cmd = ['fetch']
|
cmd = ['fetch']
|
||||||
|
|
||||||
|
# The --depth option only affects the initial fetch; after that we'll do
|
||||||
|
# full fetches of changes.
|
||||||
|
depth = self.manifest.manifestProject.config.GetString('repo.depth')
|
||||||
|
if depth and initial:
|
||||||
|
cmd.append('--depth=%s' % depth)
|
||||||
|
|
||||||
if quiet:
|
if quiet:
|
||||||
cmd.append('--quiet')
|
cmd.append('--quiet')
|
||||||
if not self.worktree:
|
if not self.worktree:
|
||||||
|
@ -82,6 +82,9 @@ to update the working directory files.
|
|||||||
g.add_option('--reference',
|
g.add_option('--reference',
|
||||||
dest='reference',
|
dest='reference',
|
||||||
help='location of mirror directory', metavar='DIR')
|
help='location of mirror directory', metavar='DIR')
|
||||||
|
g.add_option('--depth', type='int', default=None,
|
||||||
|
dest='depth',
|
||||||
|
help='create a shallow clone with given depth; see git clone')
|
||||||
|
|
||||||
# Tool
|
# Tool
|
||||||
g = p.add_option_group('repo Version options')
|
g = p.add_option_group('repo Version options')
|
||||||
@ -232,6 +235,25 @@ to update the working directory files.
|
|||||||
if a in ('y', 'yes', 't', 'true', 'on'):
|
if a in ('y', 'yes', 't', 'true', 'on'):
|
||||||
gc.SetString('color.ui', 'auto')
|
gc.SetString('color.ui', 'auto')
|
||||||
|
|
||||||
|
def _ConfigureDepth(self, opt):
|
||||||
|
"""Configure the depth we'll sync down.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
opt: Options from optparse. We care about opt.depth.
|
||||||
|
"""
|
||||||
|
# Opt.depth will be non-None if user actually passed --depth to repo init.
|
||||||
|
if opt.depth is not None:
|
||||||
|
if opt.depth > 0:
|
||||||
|
# Positive values will set the depth.
|
||||||
|
depth = str(opt.depth)
|
||||||
|
else:
|
||||||
|
# Negative numbers will clear the depth; passing None to SetString
|
||||||
|
# will do that.
|
||||||
|
depth = None
|
||||||
|
|
||||||
|
# We store the depth in the main manifest project.
|
||||||
|
self.manifest.manifestProject.config.SetString('repo.depth', depth)
|
||||||
|
|
||||||
def Execute(self, opt, args):
|
def Execute(self, opt, args):
|
||||||
git_require(MIN_GIT_VERSION, fail=True)
|
git_require(MIN_GIT_VERSION, fail=True)
|
||||||
self._SyncManifest(opt)
|
self._SyncManifest(opt)
|
||||||
@ -241,6 +263,8 @@ to update the working directory files.
|
|||||||
self._ConfigureUser()
|
self._ConfigureUser()
|
||||||
self._ConfigureColor()
|
self._ConfigureColor()
|
||||||
|
|
||||||
|
self._ConfigureDepth(opt)
|
||||||
|
|
||||||
if self.manifest.IsMirror:
|
if self.manifest.IsMirror:
|
||||||
type = 'mirror '
|
type = 'mirror '
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user