update: add update.narrow configuration option
If true, 'west update' is always '--narrow'. Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
This commit is contained in:
parent
d937dedc8b
commit
34b33ff6cb
|
@ -804,6 +804,11 @@ class Update(_ProjectCommand):
|
|||
|
||||
self.group_filter: List[str] = []
|
||||
|
||||
if args.narrow:
|
||||
self.narrow = True
|
||||
else:
|
||||
self.narrow = config.getboolean('update', 'narrow', fallback=False)
|
||||
|
||||
def handle(group_filter_item):
|
||||
item = group_filter_item.strip()
|
||||
if not item.startswith(('-', '+')):
|
||||
|
@ -1201,7 +1206,7 @@ class Update(_ProjectCommand):
|
|||
# non-commit object" error when the revision is an annotated
|
||||
# tag. ^{commit} type peeling isn't supported for the <src> in a
|
||||
# <src>:<dst> refspec, so we have to do it separately.
|
||||
if _maybe_sha(rev) and not self.args.narrow:
|
||||
if _maybe_sha(rev) and not self.narrow:
|
||||
# We can't in general fetch a SHA from a remote, as some hosts
|
||||
# forbid it for security reasons. Let's hope it's reachable
|
||||
# from some branch.
|
||||
|
@ -1222,7 +1227,7 @@ class Update(_ProjectCommand):
|
|||
log.small_banner(f'{project.name}: fetching, need revision {rev}')
|
||||
# --tags is required to get tags if we're not run as 'west
|
||||
# update --narrow', since the remote is specified as a URL.
|
||||
tags = (['--tags'] if not self.args.narrow else [])
|
||||
tags = (['--tags'] if not self.narrow else [])
|
||||
clone_depth = (['--depth', str(project.clone_depth)] if
|
||||
project.clone_depth else [])
|
||||
# -f is needed to avoid errors in case multiple remotes are
|
||||
|
|
|
@ -1040,17 +1040,27 @@ def setup_narrow(tmpdir):
|
|||
|
||||
|
||||
def test_update_narrow(tmpdir):
|
||||
# Test that 'west update --narrow' doesn't fetch tags.
|
||||
# Test that 'west update --narrow' doesn't fetch tags, and that
|
||||
# 'west update' respects the 'update.narrow' config option.
|
||||
|
||||
remote, workspace = setup_narrow(tmpdir)
|
||||
workspace.chdir()
|
||||
|
||||
cmd('update --narrow', cwd=workspace)
|
||||
def project_tags():
|
||||
return subprocess.check_output(
|
||||
[GIT, 'tag', '--list'], cwd=workspace / 'project'
|
||||
).decode().splitlines()
|
||||
|
||||
tags = subprocess.check_output(
|
||||
[GIT, 'tag', '--list'], cwd=workspace / 'project'
|
||||
).decode().splitlines()
|
||||
cmd('update --narrow')
|
||||
assert project_tags() == []
|
||||
|
||||
assert tags == []
|
||||
cmd('config update.narrow true')
|
||||
cmd('update')
|
||||
assert project_tags() == []
|
||||
|
||||
cmd('config update.narrow false')
|
||||
cmd('update')
|
||||
assert project_tags() != []
|
||||
|
||||
|
||||
def test_update_narrow_depth1(tmpdir):
|
||||
|
|
Loading…
Reference in New Issue