diff options
| author | Mike Frysinger <vapier@google.com> | 2021-02-18 15:20:15 -0500 |
|---|---|---|
| committer | Mike Frysinger <vapier@google.com> | 2021-02-18 20:38:47 +0000 |
| commit | 401c6f072564966437a74dc2f33280a85d79dc84 (patch) | |
| tree | 0b90116d29056d8cd6e1d492cbe37b516e633b6c /subcmds | |
| parent | 8c1e9e62a3214a7ab5feeb7ce194ca153cc8afb1 (diff) | |
| download | git-repo-401c6f072564966437a74dc2f33280a85d79dc84.tar.gz | |
init: make --manifest-url flag optional
Since the --manifest-url flag is always required when creating a new
checkout, allow the url to be specified via a positional argument.
This brings it a little closer to the `git clone` UI.
Change-Id: Iaf18e794ae2fa38b20579243d067205cae5fae2f
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/297322
Tested-by: Mike Frysinger <vapier@google.com>
Reviewed-by: Jonathan Nieder <jrn@google.com>
Diffstat (limited to 'subcmds')
| -rw-r--r-- | subcmds/init.py | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/subcmds/init.py b/subcmds/init.py index 1d16c856..ab0faff3 100644 --- a/subcmds/init.py +++ b/subcmds/init.py | |||
| @@ -32,9 +32,9 @@ from wrapper import Wrapper | |||
| 32 | 32 | ||
| 33 | class Init(InteractiveCommand, MirrorSafeCommand): | 33 | class Init(InteractiveCommand, MirrorSafeCommand): |
| 34 | common = True | 34 | common = True |
| 35 | helpSummary = "Initialize repo in the current directory" | 35 | helpSummary = "Initialize a repo client checkout in the current directory" |
| 36 | helpUsage = """ | 36 | helpUsage = """ |
| 37 | %prog [options] | 37 | %prog [options] [manifest url] |
| 38 | """ | 38 | """ |
| 39 | helpDescription = """ | 39 | helpDescription = """ |
| 40 | The '%prog' command is run once to install and initialize repo. | 40 | The '%prog' command is run once to install and initialize repo. |
| @@ -42,6 +42,10 @@ The latest repo source code and manifest collection is downloaded | |||
| 42 | from the server and is installed in the .repo/ directory in the | 42 | from the server and is installed in the .repo/ directory in the |
| 43 | current working directory. | 43 | current working directory. |
| 44 | 44 | ||
| 45 | When creating a new checkout, the manifest URL is the only required setting. | ||
| 46 | It may be specified using the --manifest-url option, or as the first optional | ||
| 47 | argument. | ||
| 48 | |||
| 45 | The optional -b argument can be used to select the manifest branch | 49 | The optional -b argument can be used to select the manifest branch |
| 46 | to checkout and use. If no branch is specified, the remote's default | 50 | to checkout and use. If no branch is specified, the remote's default |
| 47 | branch is used. | 51 | branch is used. |
| @@ -196,7 +200,7 @@ to update the working directory files. | |||
| 196 | 200 | ||
| 197 | if is_new: | 201 | if is_new: |
| 198 | if not opt.manifest_url: | 202 | if not opt.manifest_url: |
| 199 | print('fatal: manifest url (-u) is required.', file=sys.stderr) | 203 | print('fatal: manifest url is required.', file=sys.stderr) |
| 200 | sys.exit(1) | 204 | sys.exit(1) |
| 201 | 205 | ||
| 202 | if not opt.quiet: | 206 | if not opt.quiet: |
| @@ -498,7 +502,15 @@ to update the working directory files. | |||
| 498 | self.OptionParser.error('--mirror and --archive cannot be used together.') | 502 | self.OptionParser.error('--mirror and --archive cannot be used together.') |
| 499 | 503 | ||
| 500 | if args: | 504 | if args: |
| 501 | self.OptionParser.error('init takes no arguments') | 505 | if opt.manifest_url: |
| 506 | self.OptionParser.error( | ||
| 507 | '--manifest-url option and URL argument both specified: only use ' | ||
| 508 | 'one to select the manifest URL.') | ||
| 509 | |||
| 510 | opt.manifest_url = args.pop(0) | ||
| 511 | |||
| 512 | if args: | ||
| 513 | self.OptionParser.error('too many arguments to init') | ||
| 502 | 514 | ||
| 503 | def Execute(self, opt, args): | 515 | def Execute(self, opt, args): |
| 504 | git_require(MIN_GIT_VERSION_HARD, fail=True) | 516 | git_require(MIN_GIT_VERSION_HARD, fail=True) |
