diff options
author | Mike Frysinger <vapier@google.com> | 2025-05-22 14:14:45 -0400 |
---|---|---|
committer | LUCI <gerrit-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2025-05-27 09:26:43 -0700 |
commit | 06338abe79f1fbef61f7297530ebf11139654d6c (patch) | |
tree | 738d8ba21689be7b2e9f37b0143717c210690a95 | |
parent | 8d37f6147174fe170cc00a1d82b1cc5fe8ec0a7b (diff) | |
download | git-repo-06338abe79f1fbef61f7297530ebf11139654d6c.tar.gz |
subcmds: delete redundant dest= settings
Add a test to enforce this too.
Change-Id: I80b5cf567aa33db9c24b53428c66d69f9c1d8d74
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/478481
Commit-Queue: Mike Frysinger <vapier@google.com>
Tested-by: Mike Frysinger <vapier@google.com>
Reviewed-by: Scott Lee <ddoman@google.com>
-rw-r--r-- | subcmds/abandon.py | 1 | ||||
-rw-r--r-- | subcmds/diff.py | 1 | ||||
-rw-r--r-- | subcmds/diffmanifests.py | 5 | ||||
-rw-r--r-- | subcmds/download.py | 1 | ||||
-rw-r--r-- | subcmds/forall.py | 7 | ||||
-rw-r--r-- | subcmds/grep.py | 1 | ||||
-rw-r--r-- | subcmds/info.py | 2 | ||||
-rw-r--r-- | subcmds/list.py | 5 | ||||
-rw-r--r-- | subcmds/manifest.py | 1 | ||||
-rw-r--r-- | subcmds/overview.py | 1 | ||||
-rw-r--r-- | subcmds/rebase.py | 7 | ||||
-rw-r--r-- | subcmds/selfupdate.py | 1 | ||||
-rw-r--r-- | subcmds/stage.py | 1 | ||||
-rw-r--r-- | subcmds/start.py | 1 | ||||
-rw-r--r-- | subcmds/status.py | 1 | ||||
-rw-r--r-- | subcmds/sync.py | 16 | ||||
-rw-r--r-- | subcmds/upload.py | 4 | ||||
-rw-r--r-- | tests/test_subcmds.py | 41 |
18 files changed, 45 insertions, 52 deletions
diff --git a/subcmds/abandon.py b/subcmds/abandon.py index 3208be6b..f1688e7b 100644 --- a/subcmds/abandon.py +++ b/subcmds/abandon.py | |||
@@ -48,7 +48,6 @@ It is equivalent to "git branch -D <branchname>". | |||
48 | def _Options(self, p): | 48 | def _Options(self, p): |
49 | p.add_option( | 49 | p.add_option( |
50 | "--all", | 50 | "--all", |
51 | dest="all", | ||
52 | action="store_true", | 51 | action="store_true", |
53 | help="delete all branches in all projects", | 52 | help="delete all branches in all projects", |
54 | ) | 53 | ) |
diff --git a/subcmds/diff.py b/subcmds/diff.py index 7bb0cbbd..fe1a5139 100644 --- a/subcmds/diff.py +++ b/subcmds/diff.py | |||
@@ -35,7 +35,6 @@ to the Unix 'patch' command. | |||
35 | p.add_option( | 35 | p.add_option( |
36 | "-u", | 36 | "-u", |
37 | "--absolute", | 37 | "--absolute", |
38 | dest="absolute", | ||
39 | action="store_true", | 38 | action="store_true", |
40 | help="paths are relative to the repository root", | 39 | help="paths are relative to the repository root", |
41 | ) | 40 | ) |
diff --git a/subcmds/diffmanifests.py b/subcmds/diffmanifests.py index 3eee3f94..66b3183d 100644 --- a/subcmds/diffmanifests.py +++ b/subcmds/diffmanifests.py | |||
@@ -67,7 +67,9 @@ synced and their revisions won't be found. | |||
67 | 67 | ||
68 | def _Options(self, p): | 68 | def _Options(self, p): |
69 | p.add_option( | 69 | p.add_option( |
70 | "--raw", dest="raw", action="store_true", help="display raw diff" | 70 | "--raw", |
71 | action="store_true", | ||
72 | help="display raw diff", | ||
71 | ) | 73 | ) |
72 | p.add_option( | 74 | p.add_option( |
73 | "--no-color", | 75 | "--no-color", |
@@ -78,7 +80,6 @@ synced and their revisions won't be found. | |||
78 | ) | 80 | ) |
79 | p.add_option( | 81 | p.add_option( |
80 | "--pretty-format", | 82 | "--pretty-format", |
81 | dest="pretty_format", | ||
82 | action="store", | 83 | action="store", |
83 | metavar="<FORMAT>", | 84 | metavar="<FORMAT>", |
84 | help="print the log using a custom git pretty format string", | 85 | help="print the log using a custom git pretty format string", |
diff --git a/subcmds/download.py b/subcmds/download.py index 4396c9e7..1c0bf5ce 100644 --- a/subcmds/download.py +++ b/subcmds/download.py | |||
@@ -60,7 +60,6 @@ If no project is specified try to use current directory as a project. | |||
60 | p.add_option( | 60 | p.add_option( |
61 | "-r", | 61 | "-r", |
62 | "--revert", | 62 | "--revert", |
63 | dest="revert", | ||
64 | action="store_true", | 63 | action="store_true", |
65 | help="revert instead of checkout", | 64 | help="revert instead of checkout", |
66 | ) | 65 | ) |
diff --git a/subcmds/forall.py b/subcmds/forall.py index 9da0c96e..4bae46af 100644 --- a/subcmds/forall.py +++ b/subcmds/forall.py | |||
@@ -133,7 +133,7 @@ without iterating through the remaining projects. | |||
133 | 133 | ||
134 | @staticmethod | 134 | @staticmethod |
135 | def _cmd_option(option, _opt_str, _value, parser): | 135 | def _cmd_option(option, _opt_str, _value, parser): |
136 | setattr(parser.values, option.dest, list(parser.rargs)) | 136 | setattr(parser.values, option.dest or "command", list(parser.rargs)) |
137 | while parser.rargs: | 137 | while parser.rargs: |
138 | del parser.rargs[0] | 138 | del parser.rargs[0] |
139 | 139 | ||
@@ -141,7 +141,6 @@ without iterating through the remaining projects. | |||
141 | p.add_option( | 141 | p.add_option( |
142 | "-r", | 142 | "-r", |
143 | "--regex", | 143 | "--regex", |
144 | dest="regex", | ||
145 | action="store_true", | 144 | action="store_true", |
146 | help="execute the command only on projects matching regex or " | 145 | help="execute the command only on projects matching regex or " |
147 | "wildcard expression", | 146 | "wildcard expression", |
@@ -149,7 +148,6 @@ without iterating through the remaining projects. | |||
149 | p.add_option( | 148 | p.add_option( |
150 | "-i", | 149 | "-i", |
151 | "--inverse-regex", | 150 | "--inverse-regex", |
152 | dest="inverse_regex", | ||
153 | action="store_true", | 151 | action="store_true", |
154 | help="execute the command only on projects not matching regex or " | 152 | help="execute the command only on projects not matching regex or " |
155 | "wildcard expression", | 153 | "wildcard expression", |
@@ -157,7 +155,6 @@ without iterating through the remaining projects. | |||
157 | p.add_option( | 155 | p.add_option( |
158 | "-g", | 156 | "-g", |
159 | "--groups", | 157 | "--groups", |
160 | dest="groups", | ||
161 | help="execute the command only on projects matching the specified " | 158 | help="execute the command only on projects matching the specified " |
162 | "groups", | 159 | "groups", |
163 | ) | 160 | ) |
@@ -165,14 +162,12 @@ without iterating through the remaining projects. | |||
165 | "-c", | 162 | "-c", |
166 | "--command", | 163 | "--command", |
167 | help="command (and arguments) to execute", | 164 | help="command (and arguments) to execute", |
168 | dest="command", | ||
169 | action="callback", | 165 | action="callback", |
170 | callback=self._cmd_option, | 166 | callback=self._cmd_option, |
171 | ) | 167 | ) |
172 | p.add_option( | 168 | p.add_option( |
173 | "-e", | 169 | "-e", |
174 | "--abort-on-errors", | 170 | "--abort-on-errors", |
175 | dest="abort_on_errors", | ||
176 | action="store_true", | 171 | action="store_true", |
177 | help="abort if a command exits unsuccessfully", | 172 | help="abort if a command exits unsuccessfully", |
178 | ) | 173 | ) |
diff --git a/subcmds/grep.py b/subcmds/grep.py index 918651d9..85977ce8 100644 --- a/subcmds/grep.py +++ b/subcmds/grep.py | |||
@@ -120,7 +120,6 @@ contain a line that matches both expressions: | |||
120 | g.add_option( | 120 | g.add_option( |
121 | "-r", | 121 | "-r", |
122 | "--revision", | 122 | "--revision", |
123 | dest="revision", | ||
124 | action="append", | 123 | action="append", |
125 | metavar="TREEish", | 124 | metavar="TREEish", |
126 | help="Search TREEish, instead of the work tree", | 125 | help="Search TREEish, instead of the work tree", |
diff --git a/subcmds/info.py b/subcmds/info.py index ab230ddd..f8c2b1e3 100644 --- a/subcmds/info.py +++ b/subcmds/info.py | |||
@@ -43,14 +43,12 @@ class Info(PagedCommand): | |||
43 | p.add_option( | 43 | p.add_option( |
44 | "-o", | 44 | "-o", |
45 | "--overview", | 45 | "--overview", |
46 | dest="overview", | ||
47 | action="store_true", | 46 | action="store_true", |
48 | help="show overview of all local commits", | 47 | help="show overview of all local commits", |
49 | ) | 48 | ) |
50 | p.add_option( | 49 | p.add_option( |
51 | "-c", | 50 | "-c", |
52 | "--current-branch", | 51 | "--current-branch", |
53 | dest="current_branch", | ||
54 | action="store_true", | 52 | action="store_true", |
55 | help="consider only checked out branches", | 53 | help="consider only checked out branches", |
56 | ) | 54 | ) |
diff --git a/subcmds/list.py b/subcmds/list.py index 4338e1c9..df9ce5f6 100644 --- a/subcmds/list.py +++ b/subcmds/list.py | |||
@@ -40,7 +40,6 @@ This is similar to running: repo forall -c 'echo "$REPO_PATH : $REPO_PROJECT"'. | |||
40 | p.add_option( | 40 | p.add_option( |
41 | "-r", | 41 | "-r", |
42 | "--regex", | 42 | "--regex", |
43 | dest="regex", | ||
44 | action="store_true", | 43 | action="store_true", |
45 | help="filter the project list based on regex or wildcard matching " | 44 | help="filter the project list based on regex or wildcard matching " |
46 | "of strings", | 45 | "of strings", |
@@ -48,7 +47,6 @@ This is similar to running: repo forall -c 'echo "$REPO_PATH : $REPO_PROJECT"'. | |||
48 | p.add_option( | 47 | p.add_option( |
49 | "-g", | 48 | "-g", |
50 | "--groups", | 49 | "--groups", |
51 | dest="groups", | ||
52 | help="filter the project list based on the groups the project is " | 50 | help="filter the project list based on the groups the project is " |
53 | "in", | 51 | "in", |
54 | ) | 52 | ) |
@@ -61,21 +59,18 @@ This is similar to running: repo forall -c 'echo "$REPO_PATH : $REPO_PROJECT"'. | |||
61 | p.add_option( | 59 | p.add_option( |
62 | "-n", | 60 | "-n", |
63 | "--name-only", | 61 | "--name-only", |
64 | dest="name_only", | ||
65 | action="store_true", | 62 | action="store_true", |
66 | help="display only the name of the repository", | 63 | help="display only the name of the repository", |
67 | ) | 64 | ) |
68 | p.add_option( | 65 | p.add_option( |
69 | "-p", | 66 | "-p", |
70 | "--path-only", | 67 | "--path-only", |
71 | dest="path_only", | ||
72 | action="store_true", | 68 | action="store_true", |
73 | help="display only the path of the repository", | 69 | help="display only the path of the repository", |
74 | ) | 70 | ) |
75 | p.add_option( | 71 | p.add_option( |
76 | "-f", | 72 | "-f", |
77 | "--fullpath", | 73 | "--fullpath", |
78 | dest="fullpath", | ||
79 | action="store_true", | 74 | action="store_true", |
80 | help="display the full work tree path instead of the relative path", | 75 | help="display the full work tree path instead of the relative path", |
81 | ) | 76 | ) |
diff --git a/subcmds/manifest.py b/subcmds/manifest.py index 9786580a..548bac0d 100644 --- a/subcmds/manifest.py +++ b/subcmds/manifest.py | |||
@@ -134,7 +134,6 @@ human-readable variations. | |||
134 | p.add_option( | 134 | p.add_option( |
135 | "-o", | 135 | "-o", |
136 | "--output-file", | 136 | "--output-file", |
137 | dest="output_file", | ||
138 | default="-", | 137 | default="-", |
139 | help="file to save the manifest to. (Filename prefix for " | 138 | help="file to save the manifest to. (Filename prefix for " |
140 | "multi-tree.)", | 139 | "multi-tree.)", |
diff --git a/subcmds/overview.py b/subcmds/overview.py index 8ccad611..dff17623 100644 --- a/subcmds/overview.py +++ b/subcmds/overview.py | |||
@@ -37,7 +37,6 @@ are displayed. | |||
37 | p.add_option( | 37 | p.add_option( |
38 | "-c", | 38 | "-c", |
39 | "--current-branch", | 39 | "--current-branch", |
40 | dest="current_branch", | ||
41 | action="store_true", | 40 | action="store_true", |
42 | help="consider only checked out branches", | 41 | help="consider only checked out branches", |
43 | ) | 42 | ) |
diff --git a/subcmds/rebase.py b/subcmds/rebase.py index db1b387c..d7e769ce 100644 --- a/subcmds/rebase.py +++ b/subcmds/rebase.py | |||
@@ -47,21 +47,18 @@ branch but need to incorporate new upstream changes "underneath" them. | |||
47 | g.add_option( | 47 | g.add_option( |
48 | "-i", | 48 | "-i", |
49 | "--interactive", | 49 | "--interactive", |
50 | dest="interactive", | ||
51 | action="store_true", | 50 | action="store_true", |
52 | help="interactive rebase (single project only)", | 51 | help="interactive rebase (single project only)", |
53 | ) | 52 | ) |
54 | 53 | ||
55 | p.add_option( | 54 | p.add_option( |
56 | "--fail-fast", | 55 | "--fail-fast", |
57 | dest="fail_fast", | ||
58 | action="store_true", | 56 | action="store_true", |
59 | help="stop rebasing after first error is hit", | 57 | help="stop rebasing after first error is hit", |
60 | ) | 58 | ) |
61 | p.add_option( | 59 | p.add_option( |
62 | "-f", | 60 | "-f", |
63 | "--force-rebase", | 61 | "--force-rebase", |
64 | dest="force_rebase", | ||
65 | action="store_true", | 62 | action="store_true", |
66 | help="pass --force-rebase to git rebase", | 63 | help="pass --force-rebase to git rebase", |
67 | ) | 64 | ) |
@@ -74,27 +71,23 @@ branch but need to incorporate new upstream changes "underneath" them. | |||
74 | ) | 71 | ) |
75 | p.add_option( | 72 | p.add_option( |
76 | "--autosquash", | 73 | "--autosquash", |
77 | dest="autosquash", | ||
78 | action="store_true", | 74 | action="store_true", |
79 | help="pass --autosquash to git rebase", | 75 | help="pass --autosquash to git rebase", |
80 | ) | 76 | ) |
81 | p.add_option( | 77 | p.add_option( |
82 | "--whitespace", | 78 | "--whitespace", |
83 | dest="whitespace", | ||
84 | action="store", | 79 | action="store", |
85 | metavar="WS", | 80 | metavar="WS", |
86 | help="pass --whitespace to git rebase", | 81 | help="pass --whitespace to git rebase", |
87 | ) | 82 | ) |
88 | p.add_option( | 83 | p.add_option( |
89 | "--auto-stash", | 84 | "--auto-stash", |
90 | dest="auto_stash", | ||
91 | action="store_true", | 85 | action="store_true", |
92 | help="stash local modifications before starting", | 86 | help="stash local modifications before starting", |
93 | ) | 87 | ) |
94 | p.add_option( | 88 | p.add_option( |
95 | "-m", | 89 | "-m", |
96 | "--onto-manifest", | 90 | "--onto-manifest", |
97 | dest="onto_manifest", | ||
98 | action="store_true", | 91 | action="store_true", |
99 | help="rebase onto the manifest version instead of upstream " | 92 | help="rebase onto the manifest version instead of upstream " |
100 | "HEAD (this helps to make sure the local tree stays " | 93 | "HEAD (this helps to make sure the local tree stays " |
diff --git a/subcmds/selfupdate.py b/subcmds/selfupdate.py index 72683097..ed333569 100644 --- a/subcmds/selfupdate.py +++ b/subcmds/selfupdate.py | |||
@@ -54,7 +54,6 @@ need to be performed by an end-user. | |||
54 | ) | 54 | ) |
55 | g.add_option( | 55 | g.add_option( |
56 | "--repo-upgraded", | 56 | "--repo-upgraded", |
57 | dest="repo_upgraded", | ||
58 | action="store_true", | 57 | action="store_true", |
59 | help=optparse.SUPPRESS_HELP, | 58 | help=optparse.SUPPRESS_HELP, |
60 | ) | 59 | ) |
diff --git a/subcmds/stage.py b/subcmds/stage.py index 92a00ea0..1c285fc1 100644 --- a/subcmds/stage.py +++ b/subcmds/stage.py | |||
@@ -46,7 +46,6 @@ The '%prog' command stages files to prepare the next commit. | |||
46 | g.add_option( | 46 | g.add_option( |
47 | "-i", | 47 | "-i", |
48 | "--interactive", | 48 | "--interactive", |
49 | dest="interactive", | ||
50 | action="store_true", | 49 | action="store_true", |
51 | help="use interactive staging", | 50 | help="use interactive staging", |
52 | ) | 51 | ) |
diff --git a/subcmds/start.py b/subcmds/start.py index 6dca7e4e..73dddf3f 100644 --- a/subcmds/start.py +++ b/subcmds/start.py | |||
@@ -51,7 +51,6 @@ revision specified in the manifest. | |||
51 | def _Options(self, p): | 51 | def _Options(self, p): |
52 | p.add_option( | 52 | p.add_option( |
53 | "--all", | 53 | "--all", |
54 | dest="all", | ||
55 | action="store_true", | 54 | action="store_true", |
56 | help="begin branch in all projects", | 55 | help="begin branch in all projects", |
57 | ) | 56 | ) |
diff --git a/subcmds/status.py b/subcmds/status.py index cda73627..a9852b3c 100644 --- a/subcmds/status.py +++ b/subcmds/status.py | |||
@@ -82,7 +82,6 @@ the following meanings: | |||
82 | p.add_option( | 82 | p.add_option( |
83 | "-o", | 83 | "-o", |
84 | "--orphans", | 84 | "--orphans", |
85 | dest="orphans", | ||
86 | action="store_true", | 85 | action="store_true", |
87 | help="include objects in working directory outside of repo " | 86 | help="include objects in working directory outside of repo " |
88 | "projects", | 87 | "projects", |
diff --git a/subcmds/sync.py b/subcmds/sync.py index 3dc74f1f..3a4151df 100644 --- a/subcmds/sync.py +++ b/subcmds/sync.py | |||
@@ -373,19 +373,16 @@ later is required to fix a server side protocol bug. | |||
373 | p.add_option( | 373 | p.add_option( |
374 | "-f", | 374 | "-f", |
375 | "--force-broken", | 375 | "--force-broken", |
376 | dest="force_broken", | ||
377 | action="store_true", | 376 | action="store_true", |
378 | help="obsolete option (to be deleted in the future)", | 377 | help="obsolete option (to be deleted in the future)", |
379 | ) | 378 | ) |
380 | p.add_option( | 379 | p.add_option( |
381 | "--fail-fast", | 380 | "--fail-fast", |
382 | dest="fail_fast", | ||
383 | action="store_true", | 381 | action="store_true", |
384 | help="stop syncing after first error is hit", | 382 | help="stop syncing after first error is hit", |
385 | ) | 383 | ) |
386 | p.add_option( | 384 | p.add_option( |
387 | "--force-sync", | 385 | "--force-sync", |
388 | dest="force_sync", | ||
389 | action="store_true", | 386 | action="store_true", |
390 | help="overwrite an existing git directory if it needs to " | 387 | help="overwrite an existing git directory if it needs to " |
391 | "point to a different object directory. WARNING: this " | 388 | "point to a different object directory. WARNING: this " |
@@ -393,7 +390,6 @@ later is required to fix a server side protocol bug. | |||
393 | ) | 390 | ) |
394 | p.add_option( | 391 | p.add_option( |
395 | "--force-checkout", | 392 | "--force-checkout", |
396 | dest="force_checkout", | ||
397 | action="store_true", | 393 | action="store_true", |
398 | help="force checkout even if it results in throwing away " | 394 | help="force checkout even if it results in throwing away " |
399 | "uncommitted modifications. " | 395 | "uncommitted modifications. " |
@@ -401,7 +397,6 @@ later is required to fix a server side protocol bug. | |||
401 | ) | 397 | ) |
402 | p.add_option( | 398 | p.add_option( |
403 | "--force-remove-dirty", | 399 | "--force-remove-dirty", |
404 | dest="force_remove_dirty", | ||
405 | action="store_true", | 400 | action="store_true", |
406 | help="force remove projects with uncommitted modifications if " | 401 | help="force remove projects with uncommitted modifications if " |
407 | "projects no longer exist in the manifest. " | 402 | "projects no longer exist in the manifest. " |
@@ -409,7 +404,6 @@ later is required to fix a server side protocol bug. | |||
409 | ) | 404 | ) |
410 | p.add_option( | 405 | p.add_option( |
411 | "--rebase", | 406 | "--rebase", |
412 | dest="rebase", | ||
413 | action="store_true", | 407 | action="store_true", |
414 | help="rebase local commits regardless of whether they are " | 408 | help="rebase local commits regardless of whether they are " |
415 | "published", | 409 | "published", |
@@ -417,7 +411,6 @@ later is required to fix a server side protocol bug. | |||
417 | p.add_option( | 411 | p.add_option( |
418 | "-l", | 412 | "-l", |
419 | "--local-only", | 413 | "--local-only", |
420 | dest="local_only", | ||
421 | action="store_true", | 414 | action="store_true", |
422 | help="only update working tree, don't fetch", | 415 | help="only update working tree, don't fetch", |
423 | ) | 416 | ) |
@@ -433,7 +426,6 @@ later is required to fix a server side protocol bug. | |||
433 | p.add_option( | 426 | p.add_option( |
434 | "-n", | 427 | "-n", |
435 | "--network-only", | 428 | "--network-only", |
436 | dest="network_only", | ||
437 | action="store_true", | 429 | action="store_true", |
438 | help="fetch only, don't update working tree", | 430 | help="fetch only, don't update working tree", |
439 | ) | 431 | ) |
@@ -460,7 +452,6 @@ later is required to fix a server side protocol bug. | |||
460 | p.add_option( | 452 | p.add_option( |
461 | "-m", | 453 | "-m", |
462 | "--manifest-name", | 454 | "--manifest-name", |
463 | dest="manifest_name", | ||
464 | help="temporary manifest to use for this sync", | 455 | help="temporary manifest to use for this sync", |
465 | metavar="NAME.xml", | 456 | metavar="NAME.xml", |
466 | ) | 457 | ) |
@@ -479,19 +470,16 @@ later is required to fix a server side protocol bug. | |||
479 | "-u", | 470 | "-u", |
480 | "--manifest-server-username", | 471 | "--manifest-server-username", |
481 | action="store", | 472 | action="store", |
482 | dest="manifest_server_username", | ||
483 | help="username to authenticate with the manifest server", | 473 | help="username to authenticate with the manifest server", |
484 | ) | 474 | ) |
485 | p.add_option( | 475 | p.add_option( |
486 | "-p", | 476 | "-p", |
487 | "--manifest-server-password", | 477 | "--manifest-server-password", |
488 | action="store", | 478 | action="store", |
489 | dest="manifest_server_password", | ||
490 | help="password to authenticate with the manifest server", | 479 | help="password to authenticate with the manifest server", |
491 | ) | 480 | ) |
492 | p.add_option( | 481 | p.add_option( |
493 | "--fetch-submodules", | 482 | "--fetch-submodules", |
494 | dest="fetch_submodules", | ||
495 | action="store_true", | 483 | action="store_true", |
496 | help="fetch submodules from server", | 484 | help="fetch submodules from server", |
497 | ) | 485 | ) |
@@ -515,7 +503,6 @@ later is required to fix a server side protocol bug. | |||
515 | ) | 503 | ) |
516 | p.add_option( | 504 | p.add_option( |
517 | "--optimized-fetch", | 505 | "--optimized-fetch", |
518 | dest="optimized_fetch", | ||
519 | action="store_true", | 506 | action="store_true", |
520 | help="only fetch projects fixed to sha1 if revision does not exist " | 507 | help="only fetch projects fixed to sha1 if revision does not exist " |
521 | "locally", | 508 | "locally", |
@@ -554,7 +541,6 @@ later is required to fix a server side protocol bug. | |||
554 | p.add_option( | 541 | p.add_option( |
555 | "-s", | 542 | "-s", |
556 | "--smart-sync", | 543 | "--smart-sync", |
557 | dest="smart_sync", | ||
558 | action="store_true", | 544 | action="store_true", |
559 | help="smart sync using manifest from the latest known good " | 545 | help="smart sync using manifest from the latest known good " |
560 | "build", | 546 | "build", |
@@ -562,7 +548,6 @@ later is required to fix a server side protocol bug. | |||
562 | p.add_option( | 548 | p.add_option( |
563 | "-t", | 549 | "-t", |
564 | "--smart-tag", | 550 | "--smart-tag", |
565 | dest="smart_tag", | ||
566 | action="store", | 551 | action="store", |
567 | help="smart sync using manifest from a known tag", | 552 | help="smart sync using manifest from a known tag", |
568 | ) | 553 | ) |
@@ -577,7 +562,6 @@ later is required to fix a server side protocol bug. | |||
577 | ) | 562 | ) |
578 | g.add_option( | 563 | g.add_option( |
579 | "--repo-upgraded", | 564 | "--repo-upgraded", |
580 | dest="repo_upgraded", | ||
581 | action="store_true", | 565 | action="store_true", |
582 | help=optparse.SUPPRESS_HELP, | 566 | help=optparse.SUPPRESS_HELP, |
583 | ) | 567 | ) |
diff --git a/subcmds/upload.py b/subcmds/upload.py index 2837ff51..169a8b77 100644 --- a/subcmds/upload.py +++ b/subcmds/upload.py | |||
@@ -267,7 +267,6 @@ Gerrit Code Review: https://www.gerritcodereview.com/ | |||
267 | "--cc", | 267 | "--cc", |
268 | type="string", | 268 | type="string", |
269 | action="append", | 269 | action="append", |
270 | dest="cc", | ||
271 | help="also send email to these email addresses", | 270 | help="also send email to these email addresses", |
272 | ) | 271 | ) |
273 | p.add_option( | 272 | p.add_option( |
@@ -281,7 +280,6 @@ Gerrit Code Review: https://www.gerritcodereview.com/ | |||
281 | p.add_option( | 280 | p.add_option( |
282 | "-c", | 281 | "-c", |
283 | "--current-branch", | 282 | "--current-branch", |
284 | dest="current_branch", | ||
285 | action="store_true", | 283 | action="store_true", |
286 | help="upload current git branch", | 284 | help="upload current git branch", |
287 | ) | 285 | ) |
@@ -310,7 +308,6 @@ Gerrit Code Review: https://www.gerritcodereview.com/ | |||
310 | "-p", | 308 | "-p", |
311 | "--private", | 309 | "--private", |
312 | action="store_true", | 310 | action="store_true", |
313 | dest="private", | ||
314 | default=False, | 311 | default=False, |
315 | help="upload as a private change (deprecated; use --wip)", | 312 | help="upload as a private change (deprecated; use --wip)", |
316 | ) | 313 | ) |
@@ -318,7 +315,6 @@ Gerrit Code Review: https://www.gerritcodereview.com/ | |||
318 | "-w", | 315 | "-w", |
319 | "--wip", | 316 | "--wip", |
320 | action="store_true", | 317 | action="store_true", |
321 | dest="wip", | ||
322 | default=False, | 318 | default=False, |
323 | help="upload as a work-in-progress change", | 319 | help="upload as a work-in-progress change", |
324 | ) | 320 | ) |
diff --git a/tests/test_subcmds.py b/tests/test_subcmds.py index 5ce0776f..2d680fb7 100644 --- a/tests/test_subcmds.py +++ b/tests/test_subcmds.py | |||
@@ -89,3 +89,44 @@ class AllCommands(unittest.TestCase): | |||
89 | msg=f"subcmds/{name}.py: {opt}: only use dashes in " | 89 | msg=f"subcmds/{name}.py: {opt}: only use dashes in " |
90 | "options, not underscores", | 90 | "options, not underscores", |
91 | ) | 91 | ) |
92 | |||
93 | def test_cli_option_dest(self): | ||
94 | """Block redundant dest= arguments.""" | ||
95 | |||
96 | def _check_dest(opt): | ||
97 | if opt.dest is None or not opt._long_opts: | ||
98 | return | ||
99 | |||
100 | long = opt._long_opts[0] | ||
101 | assert long.startswith("--") | ||
102 | # This matches optparse's behavior. | ||
103 | implicit_dest = long[2:].replace("-", "_") | ||
104 | if implicit_dest == opt.dest: | ||
105 | bad_opts.append((str(opt), opt.dest)) | ||
106 | |||
107 | # Hook the option check list. | ||
108 | optparse.Option.CHECK_METHODS.insert(0, _check_dest) | ||
109 | |||
110 | # Gather all the bad options up front so people can see all bad options | ||
111 | # instead of failing at the first one. | ||
112 | all_bad_opts = {} | ||
113 | for name, cls in subcmds.all_commands.items(): | ||
114 | bad_opts = all_bad_opts[name] = [] | ||
115 | cmd = cls() | ||
116 | # Trigger construction of parser. | ||
117 | cmd.OptionParser | ||
118 | |||
119 | errmsg = None | ||
120 | for name, bad_opts in sorted(all_bad_opts.items()): | ||
121 | if bad_opts: | ||
122 | if not errmsg: | ||
123 | errmsg = "Omit redundant dest= when defining options.\n" | ||
124 | errmsg += f"\nSubcommand {name} (subcmds/{name}.py):\n" | ||
125 | errmsg += "".join( | ||
126 | f" {opt}: dest='{dest}'\n" for opt, dest in bad_opts | ||
127 | ) | ||
128 | if errmsg: | ||
129 | self.fail(errmsg) | ||
130 | |||
131 | # Make sure we aren't popping the wrong stuff. | ||
132 | assert optparse.Option.CHECK_METHODS.pop(0) is _check_dest | ||