Skip to content

Commit

Permalink
Review update: use -o for any number of git options, instead of only …
Browse files Browse the repository at this point in the history
…introducing --depth
  • Loading branch information
usmanimtiaz63 committed Oct 4, 2024
1 parent e20af42 commit 5c29f0b
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/west/app/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ def do_add_parser(self, parser_adder):
parser_adder,
usage='''
%(prog)s [-m URL] [--mr REVISION] [--mf FILE] [directory] [-d CLONE_DEPTH]
%(prog)s [-m URL] [--mr REVISION] [--mf FILE] [directory] [-o=MORE_GIT_OPTIONS]
%(prog)s -l [--mf FILE] directory
''')

Expand All @@ -186,8 +186,9 @@ def do_add_parser(self, parser_adder):
parser.add_argument('-m', '--manifest-url',
help='''manifest repository URL to clone;
cannot be combined with -l''')
parser.add_argument('-d', '--depth',
help='''clone depth of repository;
parser.add_argument('-o', '--clone-opt', action='append', default=[],
help='''additional option to pass to 'git clone'
(e.g. '-o=--depth=1'); may be given more than once;
cannot be combined with -l''')
parser.add_argument('--mr', '--manifest-rev', dest='manifest_rev',
help='''manifest repository branch or tag name
Expand Down Expand Up @@ -228,8 +229,8 @@ def do_run(self, args, _):

self.die_already(self.topdir, msg)

if args.local and (args.manifest_url or args.manifest_rev or args.depth):
self.die('-l cannot be combined with -m, -d or --mr')
if args.local and (args.manifest_url or args.manifest_rev or args.clone_opt):
self.die('-l cannot be combined with -m, -o or --mr')

self.die_if_no_git()

Expand Down Expand Up @@ -284,7 +285,6 @@ def bootstrap(self, args) -> Path:
branch_opt = ['--branch', args.manifest_rev]
else:
branch_opt = []
init_depth = f'--depth={args.depth}' if args.depth else ''
west_dir = topdir / WEST_DIR

try:
Expand All @@ -306,7 +306,7 @@ def bootstrap(self, args) -> Path:
f'Cloning manifest repository from {manifest_url}' +
(f', rev. {args.manifest_rev}' if args.manifest_rev else ''))

self.check_call(['git', 'clone'] + branch_opt + [init_depth] +
self.check_call(['git', 'clone'] + branch_opt + args.clone_opt +
[manifest_url, os.fspath(tempdir)])
except subprocess.CalledProcessError:
shutil.rmtree(tempdir, ignore_errors=True)
Expand Down

0 comments on commit 5c29f0b

Please sign in to comment.