Skip to content

Commit

Permalink
Add option to specify git clone options like --depth for Zephyr repo …
Browse files Browse the repository at this point in the history
…clone via init
  • Loading branch information
usmanimtiaz63 authored and pdgendt committed Oct 10, 2024
1 parent 0beff99 commit 69da5d1
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 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]
%(prog)s [-m URL] [--mr REVISION] [--mf FILE] [-o=GIT_CLONE_OPTION] [directory]
%(prog)s -l [--mf FILE] directory
''')

Expand All @@ -186,6 +186,10 @@ 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('-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
to check out first; cannot be combined with -l''')
Expand Down Expand Up @@ -225,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):
self.die('-l cannot be combined with -m 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 @@ -302,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 +
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 69da5d1

Please sign in to comment.