summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Frysinger <vapier@google.com>2021-04-08 19:14:15 -0400
committerMike Frysinger <vapier@google.com>2021-04-09 01:04:32 +0000
commit9a734a3975c1fc45a43466f1a42e3f2ca588bd19 (patch)
tree287131f8b60694e34d629c0b74597559512b89db
parent6a2f4fb39073a4e2e6824d5f2f4a1cbf5fe4b766 (diff)
downloadgit-repo-9a734a3975c1fc45a43466f1a42e3f2ca588bd19.tar.gz
init: merge subcmd & wrapper parsers
These are manually kept in sync which is a pain. Have the init subcmd reuse the wrapper code directly. Change-Id: Ica73211422c64377bacc9bb3b1d1a8d9d5f7f4ca Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/302762 Reviewed-by: Raman Tenneti <rtenneti@google.com> Tested-by: Mike Frysinger <vapier@google.com>
-rwxr-xr-xrepo5
-rw-r--r--subcmds/gitc_init.py7
-rw-r--r--subcmds/init.py103
3 files changed, 6 insertions, 109 deletions
diff --git a/repo b/repo
index 80db98d2..876a48d9 100755
--- a/repo
+++ b/repo
@@ -275,7 +275,12 @@ def GetParser(gitc_init=False):
275 usage = 'repo init [options] [-u] url' 275 usage = 'repo init [options] [-u] url'
276 276
277 parser = optparse.OptionParser(usage=usage) 277 parser = optparse.OptionParser(usage=usage)
278 InitParser(parser, gitc_init=gitc_init)
279 return parser
280
278 281
282def InitParser(parser, gitc_init=False):
283 """Setup the CLI parser."""
279 # Logging. 284 # Logging.
280 group = parser.add_option_group('Logging options') 285 group = parser.add_option_group('Logging options')
281 group.add_option('-v', '--verbose', 286 group.add_option('-v', '--verbose',
diff --git a/subcmds/gitc_init.py b/subcmds/gitc_init.py
index 89472edb..23a4ebb6 100644
--- a/subcmds/gitc_init.py
+++ b/subcmds/gitc_init.py
@@ -48,13 +48,6 @@ use for this GITC client.
48 48
49 def _Options(self, p): 49 def _Options(self, p):
50 super()._Options(p, gitc_init=True) 50 super()._Options(p, gitc_init=True)
51 g = p.add_option_group('GITC options')
52 g.add_option('-f', '--manifest-file',
53 dest='manifest_file',
54 help='Optional manifest file to use for this GITC client.')
55 g.add_option('-c', '--gitc-client',
56 dest='gitc_client',
57 help='The name of the gitc_client instance to create or modify.')
58 51
59 def Execute(self, opt, args): 52 def Execute(self, opt, args):
60 gitc_client = gitc_utils.parse_clientdir(os.getcwd()) 53 gitc_client = gitc_utils.parse_clientdir(os.getcwd())
diff --git a/subcmds/init.py b/subcmds/init.py
index f16bee6d..3566b8b6 100644
--- a/subcmds/init.py
+++ b/subcmds/init.py
@@ -80,108 +80,7 @@ to update the working directory files.
80""" 80"""
81 81
82 def _Options(self, p, gitc_init=False): 82 def _Options(self, p, gitc_init=False):
83 # Logging 83 Wrapper().InitParser(p, gitc_init=gitc_init)
84 g = p.add_option_group('Logging options')
85 g.add_option('-v', '--verbose',
86 dest='output_mode', action='store_true',
87 help='show all output')
88 g.add_option('-q', '--quiet',
89 dest='output_mode', action='store_false',
90 help='only show errors')
91
92 # Manifest
93 g = p.add_option_group('Manifest options')
94 g.add_option('-u', '--manifest-url',
95 dest='manifest_url',
96 help='manifest repository location', metavar='URL')
97 g.add_option('-b', '--manifest-branch', metavar='REVISION',
98 help='manifest branch or revision (use HEAD for default)')
99 cbr_opts = ['--current-branch']
100 # The gitc-init subcommand allocates -c itself, but a lot of init users
101 # want -c, so try to satisfy both as best we can.
102 if not gitc_init:
103 cbr_opts += ['-c']
104 g.add_option(*cbr_opts,
105 dest='current_branch_only', action='store_true',
106 help='fetch only current manifest branch from server')
107 g.add_option('-m', '--manifest-name',
108 dest='manifest_name', default='default.xml',
109 help='initial manifest file', metavar='NAME.xml')
110 g.add_option('--mirror',
111 dest='mirror', action='store_true',
112 help='create a replica of the remote repositories '
113 'rather than a client working directory')
114 g.add_option('--reference',
115 dest='reference',
116 help='location of mirror directory', metavar='DIR')
117 g.add_option('--dissociate',
118 dest='dissociate', action='store_true',
119 help='dissociate from reference mirrors after clone')
120 g.add_option('--depth', type='int', default=None,
121 dest='depth',
122 help='create a shallow clone with given depth; see git clone')
123 g.add_option('--partial-clone', action='store_true',
124 dest='partial_clone',
125 help='perform partial clone (https://git-scm.com/'
126 'docs/gitrepository-layout#_code_partialclone_code)')
127 g.add_option('--no-partial-clone', action='store_false',
128 dest='partial_clone',
129 help='disable use of partial clone (https://git-scm.com/'
130 'docs/gitrepository-layout#_code_partialclone_code)')
131 g.add_option('--clone-filter', action='store', default='blob:none',
132 dest='clone_filter',
133 help='filter for use with --partial-clone [default: %default]')
134 g.add_option('--worktree', action='store_true',
135 help='use git-worktree to manage projects')
136 g.add_option('--archive',
137 dest='archive', action='store_true',
138 help='checkout an archive instead of a git repository for '
139 'each project. See git archive.')
140 g.add_option('--submodules',
141 dest='submodules', action='store_true',
142 help='sync any submodules associated with the manifest repo')
143 g.add_option('--use-superproject', action='store_true',
144 help='use the manifest superproject to sync projects')
145 g.add_option('--no-use-superproject', action='store_false',
146 dest='use_superproject',
147 help='disable use of manifest superprojects')
148 g.add_option('-g', '--groups',
149 dest='groups', default='default',
150 help='restrict manifest projects to ones with specified '
151 'group(s) [default|all|G1,G2,G3|G4,-G5,-G6]',
152 metavar='GROUP')
153 g.add_option('-p', '--platform',
154 dest='platform', default='auto',
155 help='restrict manifest projects to ones with a specified '
156 'platform group [auto|all|none|linux|darwin|...]',
157 metavar='PLATFORM')
158 g.add_option('--clone-bundle', action='store_true',
159 help='force use of /clone.bundle on HTTP/HTTPS (default if not --partial-clone)')
160 g.add_option('--no-clone-bundle',
161 dest='clone_bundle', action='store_false',
162 help='disable use of /clone.bundle on HTTP/HTTPS (default if --partial-clone)')
163 g.add_option('--no-tags',
164 dest='tags', default=True, action='store_false',
165 help="don't fetch tags in the manifest")
166
167 # Tool
168 g = p.add_option_group('repo Version options')
169 g.add_option('--repo-url',
170 dest='repo_url',
171 help='repo repository location', metavar='URL')
172 g.add_option('--repo-rev', metavar='REV',
173 help='repo branch or revision')
174 g.add_option('--repo-branch', dest='repo_rev',
175 help=optparse.SUPPRESS_HELP)
176 g.add_option('--no-repo-verify',
177 dest='repo_verify', default=True, action='store_false',
178 help='do not verify repo source code')
179
180 # Other
181 g = p.add_option_group('Other options')
182 g.add_option('--config-name',
183 dest='config_name', action="store_true", default=False,
184 help='Always prompt for name/e-mail')
185 84
186 def _RegisteredEnvironmentOptions(self): 85 def _RegisteredEnvironmentOptions(self):
187 return {'REPO_MANIFEST_URL': 'manifest_url', 86 return {'REPO_MANIFEST_URL': 'manifest_url',