summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--subcmds/diff.py2
-rw-r--r--subcmds/diffmanifests.py4
-rw-r--r--subcmds/forall.py16
-rw-r--r--subcmds/gitc_delete.py2
-rw-r--r--subcmds/info.py2
-rw-r--r--subcmds/list.py12
-rw-r--r--subcmds/manifest.py20
-rw-r--r--subcmds/overview.py2
-rw-r--r--subcmds/rebase.py18
-rw-r--r--subcmds/sync.py9
-rw-r--r--subcmds/upload.py34
-rw-r--r--tests/test_subcmds.py30
12 files changed, 91 insertions, 60 deletions
diff --git a/subcmds/diff.py b/subcmds/diff.py
index 4966bb1a..b400ccfd 100644
--- a/subcmds/diff.py
+++ b/subcmds/diff.py
@@ -33,7 +33,7 @@ to the Unix 'patch' command.
33 def _Options(self, p): 33 def _Options(self, p):
34 p.add_option('-u', '--absolute', 34 p.add_option('-u', '--absolute',
35 dest='absolute', action='store_true', 35 dest='absolute', action='store_true',
36 help='Paths are relative to the repository root') 36 help='paths are relative to the repository root')
37 37
38 def _ExecuteOne(self, absolute, project): 38 def _ExecuteOne(self, absolute, project):
39 """Obtains the diff for a specific project. 39 """Obtains the diff for a specific project.
diff --git a/subcmds/diffmanifests.py b/subcmds/diffmanifests.py
index 392e5972..6f23b345 100644
--- a/subcmds/diffmanifests.py
+++ b/subcmds/diffmanifests.py
@@ -68,10 +68,10 @@ synced and their revisions won't be found.
68 def _Options(self, p): 68 def _Options(self, p):
69 p.add_option('--raw', 69 p.add_option('--raw',
70 dest='raw', action='store_true', 70 dest='raw', action='store_true',
71 help='Display raw diff.') 71 help='display raw diff')
72 p.add_option('--no-color', 72 p.add_option('--no-color',
73 dest='color', action='store_false', default=True, 73 dest='color', action='store_false', default=True,
74 help='does not display the diff in color.') 74 help='does not display the diff in color')
75 p.add_option('--pretty-format', 75 p.add_option('--pretty-format',
76 dest='pretty_format', action='store', 76 dest='pretty_format', action='store',
77 metavar='<FORMAT>', 77 metavar='<FORMAT>',
diff --git a/subcmds/forall.py b/subcmds/forall.py
index 4a631fb7..0cf3b6a6 100644
--- a/subcmds/forall.py
+++ b/subcmds/forall.py
@@ -131,30 +131,30 @@ without iterating through the remaining projects.
131 def _Options(self, p): 131 def _Options(self, p):
132 p.add_option('-r', '--regex', 132 p.add_option('-r', '--regex',
133 dest='regex', action='store_true', 133 dest='regex', action='store_true',
134 help="Execute the command only on projects matching regex or wildcard expression") 134 help='execute the command only on projects matching regex or wildcard expression')
135 p.add_option('-i', '--inverse-regex', 135 p.add_option('-i', '--inverse-regex',
136 dest='inverse_regex', action='store_true', 136 dest='inverse_regex', action='store_true',
137 help="Execute the command only on projects not matching regex or " 137 help='execute the command only on projects not matching regex or '
138 "wildcard expression") 138 'wildcard expression')
139 p.add_option('-g', '--groups', 139 p.add_option('-g', '--groups',
140 dest='groups', 140 dest='groups',
141 help="Execute the command only on projects matching the specified groups") 141 help='execute the command only on projects matching the specified groups')
142 p.add_option('-c', '--command', 142 p.add_option('-c', '--command',
143 help='Command (and arguments) to execute', 143 help='command (and arguments) to execute',
144 dest='command', 144 dest='command',
145 action='callback', 145 action='callback',
146 callback=self._cmd_option) 146 callback=self._cmd_option)
147 p.add_option('-e', '--abort-on-errors', 147 p.add_option('-e', '--abort-on-errors',
148 dest='abort_on_errors', action='store_true', 148 dest='abort_on_errors', action='store_true',
149 help='Abort if a command exits unsuccessfully') 149 help='abort if a command exits unsuccessfully')
150 p.add_option('--ignore-missing', action='store_true', 150 p.add_option('--ignore-missing', action='store_true',
151 help='Silently skip & do not exit non-zero due missing ' 151 help='silently skip & do not exit non-zero due missing '
152 'checkouts') 152 'checkouts')
153 153
154 g = p.get_option_group('--quiet') 154 g = p.get_option_group('--quiet')
155 g.add_option('-p', 155 g.add_option('-p',
156 dest='project_header', action='store_true', 156 dest='project_header', action='store_true',
157 help='Show project headers before output') 157 help='show project headers before output')
158 p.add_option('--interactive', 158 p.add_option('--interactive',
159 action='store_true', 159 action='store_true',
160 help='force interactive usage') 160 help='force interactive usage')
diff --git a/subcmds/gitc_delete.py b/subcmds/gitc_delete.py
index 56e0eaba..54b956f7 100644
--- a/subcmds/gitc_delete.py
+++ b/subcmds/gitc_delete.py
@@ -33,7 +33,7 @@ and all locally downloaded sources.
33 def _Options(self, p): 33 def _Options(self, p):
34 p.add_option('-f', '--force', 34 p.add_option('-f', '--force',
35 dest='force', action='store_true', 35 dest='force', action='store_true',
36 help='Force the deletion (no prompt).') 36 help='force the deletion (no prompt)')
37 37
38 def Execute(self, opt, args): 38 def Execute(self, opt, args):
39 if not opt.force: 39 if not opt.force:
diff --git a/subcmds/info.py b/subcmds/info.py
index 2be56109..f7cf60fc 100644
--- a/subcmds/info.py
+++ b/subcmds/info.py
@@ -48,7 +48,7 @@ class Info(PagedCommand):
48 help=optparse.SUPPRESS_HELP) 48 help=optparse.SUPPRESS_HELP)
49 p.add_option('-l', '--local-only', 49 p.add_option('-l', '--local-only',
50 dest="local", action="store_true", 50 dest="local", action="store_true",
51 help="Disable all remote operations") 51 help="disable all remote operations")
52 52
53 def Execute(self, opt, args): 53 def Execute(self, opt, args):
54 self.out = _Coloring(self.client.globalConfig) 54 self.out = _Coloring(self.client.globalConfig)
diff --git a/subcmds/list.py b/subcmds/list.py
index 5cbc0c22..68bcd5e0 100644
--- a/subcmds/list.py
+++ b/subcmds/list.py
@@ -36,22 +36,22 @@ This is similar to running: repo forall -c 'echo "$REPO_PATH : $REPO_PROJECT"'.
36 def _Options(self, p): 36 def _Options(self, p):
37 p.add_option('-r', '--regex', 37 p.add_option('-r', '--regex',
38 dest='regex', action='store_true', 38 dest='regex', action='store_true',
39 help="Filter the project list based on regex or wildcard matching of strings") 39 help='filter the project list based on regex or wildcard matching of strings')
40 p.add_option('-g', '--groups', 40 p.add_option('-g', '--groups',
41 dest='groups', 41 dest='groups',
42 help="Filter the project list based on the groups the project is in") 42 help='filter the project list based on the groups the project is in')
43 p.add_option('-a', '--all', 43 p.add_option('-a', '--all',
44 action='store_true', 44 action='store_true',
45 help='Show projects regardless of checkout state') 45 help='show projects regardless of checkout state')
46 p.add_option('-f', '--fullpath', 46 p.add_option('-f', '--fullpath',
47 dest='fullpath', action='store_true', 47 dest='fullpath', action='store_true',
48 help="Display the full work tree path instead of the relative path") 48 help='display the full work tree path instead of the relative path')
49 p.add_option('-n', '--name-only', 49 p.add_option('-n', '--name-only',
50 dest='name_only', action='store_true', 50 dest='name_only', action='store_true',
51 help="Display only the name of the repository") 51 help='display only the name of the repository')
52 p.add_option('-p', '--path-only', 52 p.add_option('-p', '--path-only',
53 dest='path_only', action='store_true', 53 dest='path_only', action='store_true',
54 help="Display only the path of the repository") 54 help='display only the path of the repository')
55 55
56 def ValidateOptions(self, opt, args): 56 def ValidateOptions(self, opt, args):
57 if opt.fullpath and opt.name_only: 57 if opt.fullpath and opt.name_only:
diff --git a/subcmds/manifest.py b/subcmds/manifest.py
index e33e683c..965c36e9 100644
--- a/subcmds/manifest.py
+++ b/subcmds/manifest.py
@@ -53,27 +53,27 @@ to indicate the remote ref to push changes to via 'repo upload'.
53 def _Options(self, p): 53 def _Options(self, p):
54 p.add_option('-r', '--revision-as-HEAD', 54 p.add_option('-r', '--revision-as-HEAD',
55 dest='peg_rev', action='store_true', 55 dest='peg_rev', action='store_true',
56 help='Save revisions as current HEAD') 56 help='save revisions as current HEAD')
57 p.add_option('-m', '--manifest-name', 57 p.add_option('-m', '--manifest-name',
58 help='temporary manifest to use for this sync', metavar='NAME.xml') 58 help='temporary manifest to use for this sync', metavar='NAME.xml')
59 p.add_option('--suppress-upstream-revision', dest='peg_rev_upstream', 59 p.add_option('--suppress-upstream-revision', dest='peg_rev_upstream',
60 default=True, action='store_false', 60 default=True, action='store_false',
61 help='If in -r mode, do not write the upstream field. ' 61 help='if in -r mode, do not write the upstream field '
62 'Only of use if the branch names for a sha1 manifest are ' 62 '(only of use if the branch names for a sha1 manifest are '
63 'sensitive.') 63 'sensitive)')
64 p.add_option('--suppress-dest-branch', dest='peg_rev_dest_branch', 64 p.add_option('--suppress-dest-branch', dest='peg_rev_dest_branch',
65 default=True, action='store_false', 65 default=True, action='store_false',
66 help='If in -r mode, do not write the dest-branch field. ' 66 help='if in -r mode, do not write the dest-branch field '
67 'Only of use if the branch names for a sha1 manifest are ' 67 '(only of use if the branch names for a sha1 manifest are '
68 'sensitive.') 68 'sensitive)')
69 p.add_option('--json', default=False, action='store_true', 69 p.add_option('--json', default=False, action='store_true',
70 help='Output manifest in JSON format (experimental).') 70 help='output manifest in JSON format (experimental)')
71 p.add_option('--pretty', default=False, action='store_true', 71 p.add_option('--pretty', default=False, action='store_true',
72 help='Format output for humans to read.') 72 help='format output for humans to read')
73 p.add_option('-o', '--output-file', 73 p.add_option('-o', '--output-file',
74 dest='output_file', 74 dest='output_file',
75 default='-', 75 default='-',
76 help='File to save the manifest to', 76 help='file to save the manifest to',
77 metavar='-|NAME.xml') 77 metavar='-|NAME.xml')
78 78
79 def _Output(self, opt): 79 def _Output(self, opt):
diff --git a/subcmds/overview.py b/subcmds/overview.py
index 202a5eba..b28367be 100644
--- a/subcmds/overview.py
+++ b/subcmds/overview.py
@@ -36,7 +36,7 @@ are displayed.
36 def _Options(self, p): 36 def _Options(self, p):
37 p.add_option('-c', '--current-branch', 37 p.add_option('-c', '--current-branch',
38 dest="current_branch", action="store_true", 38 dest="current_branch", action="store_true",
39 help="Consider only checked out branches") 39 help="consider only checked out branches")
40 p.add_option('--no-current-branch', 40 p.add_option('--no-current-branch',
41 dest='current_branch', action='store_false', 41 dest='current_branch', action='store_false',
42 help='consider all local branches') 42 help='consider all local branches')
diff --git a/subcmds/rebase.py b/subcmds/rebase.py
index e0186d4d..9ce4ecb8 100644
--- a/subcmds/rebase.py
+++ b/subcmds/rebase.py
@@ -46,27 +46,27 @@ branch but need to incorporate new upstream changes "underneath" them.
46 46
47 p.add_option('--fail-fast', 47 p.add_option('--fail-fast',
48 dest='fail_fast', action='store_true', 48 dest='fail_fast', action='store_true',
49 help='Stop rebasing after first error is hit') 49 help='stop rebasing after first error is hit')
50 p.add_option('-f', '--force-rebase', 50 p.add_option('-f', '--force-rebase',
51 dest='force_rebase', action='store_true', 51 dest='force_rebase', action='store_true',
52 help='Pass --force-rebase to git rebase') 52 help='pass --force-rebase to git rebase')
53 p.add_option('--no-ff', 53 p.add_option('--no-ff',
54 dest='ff', default=True, action='store_false', 54 dest='ff', default=True, action='store_false',
55 help='Pass --no-ff to git rebase') 55 help='pass --no-ff to git rebase')
56 p.add_option('--autosquash', 56 p.add_option('--autosquash',
57 dest='autosquash', action='store_true', 57 dest='autosquash', action='store_true',
58 help='Pass --autosquash to git rebase') 58 help='pass --autosquash to git rebase')
59 p.add_option('--whitespace', 59 p.add_option('--whitespace',
60 dest='whitespace', action='store', metavar='WS', 60 dest='whitespace', action='store', metavar='WS',
61 help='Pass --whitespace to git rebase') 61 help='pass --whitespace to git rebase')
62 p.add_option('--auto-stash', 62 p.add_option('--auto-stash',
63 dest='auto_stash', action='store_true', 63 dest='auto_stash', action='store_true',
64 help='Stash local modifications before starting') 64 help='stash local modifications before starting')
65 p.add_option('-m', '--onto-manifest', 65 p.add_option('-m', '--onto-manifest',
66 dest='onto_manifest', action='store_true', 66 dest='onto_manifest', action='store_true',
67 help='Rebase onto the manifest version instead of upstream ' 67 help='rebase onto the manifest version instead of upstream '
68 'HEAD. This helps to make sure the local tree stays ' 68 'HEAD (this helps to make sure the local tree stays '
69 'consistent if you previously synced to a manifest.') 69 'consistent if you previously synced to a manifest)')
70 70
71 def Execute(self, opt, args): 71 def Execute(self, opt, args):
72 all_projects = self.GetProjects(args) 72 all_projects = self.GetProjects(args)
diff --git a/subcmds/sync.py b/subcmds/sync.py
index e5280865..31760e5c 100644
--- a/subcmds/sync.py
+++ b/subcmds/sync.py
@@ -169,10 +169,11 @@ later is required to fix a server side protocol bug.
169 PARALLEL_JOBS = 1 169 PARALLEL_JOBS = 1
170 170
171 def _CommonOptions(self, p): 171 def _CommonOptions(self, p):
172 try: 172 if self.manifest:
173 self.PARALLEL_JOBS = self.manifest.default.sync_j 173 try:
174 except ManifestParseError: 174 self.PARALLEL_JOBS = self.manifest.default.sync_j
175 pass 175 except ManifestParseError:
176 pass
176 super()._CommonOptions(p) 177 super()._CommonOptions(p)
177 178
178 def _Options(self, p, show_smart=True): 179 def _Options(self, p, show_smart=True):
diff --git a/subcmds/upload.py b/subcmds/upload.py
index c497d877..fc389e42 100644
--- a/subcmds/upload.py
+++ b/subcmds/upload.py
@@ -152,61 +152,61 @@ Gerrit Code Review: https://www.gerritcodereview.com/
152 def _Options(self, p): 152 def _Options(self, p):
153 p.add_option('-t', 153 p.add_option('-t',
154 dest='auto_topic', action='store_true', 154 dest='auto_topic', action='store_true',
155 help='Send local branch name to Gerrit Code Review') 155 help='send local branch name to Gerrit Code Review')
156 p.add_option('--hashtag', '--ht', 156 p.add_option('--hashtag', '--ht',
157 dest='hashtags', action='append', default=[], 157 dest='hashtags', action='append', default=[],
158 help='Add hashtags (comma delimited) to the review.') 158 help='add hashtags (comma delimited) to the review')
159 p.add_option('--hashtag-branch', '--htb', 159 p.add_option('--hashtag-branch', '--htb',
160 action='store_true', 160 action='store_true',
161 help='Add local branch name as a hashtag.') 161 help='add local branch name as a hashtag')
162 p.add_option('-l', '--label', 162 p.add_option('-l', '--label',
163 dest='labels', action='append', default=[], 163 dest='labels', action='append', default=[],
164 help='Add a label when uploading.') 164 help='add a label when uploading')
165 p.add_option('--re', '--reviewers', 165 p.add_option('--re', '--reviewers',
166 type='string', action='append', dest='reviewers', 166 type='string', action='append', dest='reviewers',
167 help='Request reviews from these people.') 167 help='request reviews from these people')
168 p.add_option('--cc', 168 p.add_option('--cc',
169 type='string', action='append', dest='cc', 169 type='string', action='append', dest='cc',
170 help='Also send email to these email addresses.') 170 help='also send email to these email addresses')
171 p.add_option('--br', '--branch', 171 p.add_option('--br', '--branch',
172 type='string', action='store', dest='branch', 172 type='string', action='store', dest='branch',
173 help='(Local) branch to upload.') 173 help='(local) branch to upload')
174 p.add_option('-c', '--current-branch', 174 p.add_option('-c', '--current-branch',
175 dest='current_branch', action='store_true', 175 dest='current_branch', action='store_true',
176 help='Upload current git branch.') 176 help='upload current git branch')
177 p.add_option('--no-current-branch', 177 p.add_option('--no-current-branch',
178 dest='current_branch', action='store_false', 178 dest='current_branch', action='store_false',
179 help='Upload all git branches.') 179 help='upload all git branches')
180 # Turn this into a warning & remove this someday. 180 # Turn this into a warning & remove this someday.
181 p.add_option('--cbr', 181 p.add_option('--cbr',
182 dest='current_branch', action='store_true', 182 dest='current_branch', action='store_true',
183 help=optparse.SUPPRESS_HELP) 183 help=optparse.SUPPRESS_HELP)
184 p.add_option('--ne', '--no-emails', 184 p.add_option('--ne', '--no-emails',
185 action='store_false', dest='notify', default=True, 185 action='store_false', dest='notify', default=True,
186 help='If specified, do not send emails on upload.') 186 help='do not send e-mails on upload')
187 p.add_option('-p', '--private', 187 p.add_option('-p', '--private',
188 action='store_true', dest='private', default=False, 188 action='store_true', dest='private', default=False,
189 help='If specified, upload as a private change.') 189 help='upload as a private change (deprecated; use --wip)')
190 p.add_option('-w', '--wip', 190 p.add_option('-w', '--wip',
191 action='store_true', dest='wip', default=False, 191 action='store_true', dest='wip', default=False,
192 help='If specified, upload as a work-in-progress change.') 192 help='upload as a work-in-progress change')
193 p.add_option('-o', '--push-option', 193 p.add_option('-o', '--push-option',
194 type='string', action='append', dest='push_options', 194 type='string', action='append', dest='push_options',
195 default=[], 195 default=[],
196 help='Additional push options to transmit') 196 help='additional push options to transmit')
197 p.add_option('-D', '--destination', '--dest', 197 p.add_option('-D', '--destination', '--dest',
198 type='string', action='store', dest='dest_branch', 198 type='string', action='store', dest='dest_branch',
199 metavar='BRANCH', 199 metavar='BRANCH',
200 help='Submit for review on this target branch.') 200 help='submit for review on this target branch')
201 p.add_option('-n', '--dry-run', 201 p.add_option('-n', '--dry-run',
202 dest='dryrun', default=False, action='store_true', 202 dest='dryrun', default=False, action='store_true',
203 help='Do everything except actually upload the CL.') 203 help='do everything except actually upload the CL')
204 p.add_option('-y', '--yes', 204 p.add_option('-y', '--yes',
205 default=False, action='store_true', 205 default=False, action='store_true',
206 help='Answer yes to all safe prompts.') 206 help='answer yes to all safe prompts')
207 p.add_option('--no-cert-checks', 207 p.add_option('--no-cert-checks',
208 dest='validate_certs', action='store_false', default=True, 208 dest='validate_certs', action='store_false', default=True,
209 help='Disable verifying ssl certs (unsafe).') 209 help='disable verifying ssl certs (unsafe)')
210 RepoHook.AddOptionGroup(p, 'pre-upload') 210 RepoHook.AddOptionGroup(p, 'pre-upload')
211 211
212 def _SingleBranch(self, opt, branch, people): 212 def _SingleBranch(self, opt, branch, people):
diff --git a/tests/test_subcmds.py b/tests/test_subcmds.py
index 2234e646..bc53051a 100644
--- a/tests/test_subcmds.py
+++ b/tests/test_subcmds.py
@@ -14,6 +14,7 @@
14 14
15"""Unittests for the subcmds module (mostly __init__.py than subcommands).""" 15"""Unittests for the subcmds module (mostly __init__.py than subcommands)."""
16 16
17import optparse
17import unittest 18import unittest
18 19
19import subcmds 20import subcmds
@@ -41,3 +42,32 @@ class AllCommands(unittest.TestCase):
41 42
42 # Reject internal python paths like "__init__". 43 # Reject internal python paths like "__init__".
43 self.assertFalse(cmd.startswith('__')) 44 self.assertFalse(cmd.startswith('__'))
45
46 def test_help_desc_style(self):
47 """Force some consistency in option descriptions.
48
49 Python's optparse & argparse has a few default options like --help. Their
50 option description text uses lowercase sentence fragments, so enforce our
51 options follow the same style so UI is consistent.
52
53 We enforce:
54 * Text starts with lowercase.
55 * Text doesn't end with period.
56 """
57 for name, cls in subcmds.all_commands.items():
58 cmd = cls()
59 parser = cmd.OptionParser
60 for option in parser.option_list:
61 if option.help == optparse.SUPPRESS_HELP:
62 continue
63
64 c = option.help[0]
65 self.assertEqual(
66 c.lower(), c,
67 msg=f'subcmds/{name}.py: {option.get_opt_string()}: help text '
68 f'should start with lowercase: "{option.help}"')
69
70 self.assertNotEqual(
71 option.help[-1], '.',
72 msg=f'subcmds/{name}.py: {option.get_opt_string()}: help text '
73 f'should not end in a period: "{option.help}"')