diff options
| author | Mike Frysinger <vapier@google.com> | 2025-09-15 10:23:20 -0400 |
|---|---|---|
| committer | LUCI <gerrit-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2025-09-17 12:54:30 -0700 |
| commit | d30414bb5331d91784c536d30e22c2ccb8126b7a (patch) | |
| tree | 03b21e8932c7510ae11fb9b27137108f51e585ce /tests | |
| parent | 80d1a5ad3ec862c64a3bbe9919d4547340950183 (diff) | |
| download | git-repo-d30414bb5331d91784c536d30e22c2ccb8126b7a.tar.gz | |
forall: fix crash with no command
When callback= is used, optparse does not automatically initialize
The destination when a dest= is not specified. Refine the test to
allow dest= options when callback= is used even when it seems like
it is otherwise redundant.
Bug: b/436611422
Change-Id: I5185f95cb857ca6d37357cac77fb117a83db9c0c
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/509861
Tested-by: Mike Frysinger <vapier@google.com>
Commit-Queue: Mike Frysinger <vapier@google.com>
Reviewed-by: Gavin Mak <gavinmak@google.com>
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test_subcmds.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/tests/test_subcmds.py b/tests/test_subcmds.py index 2d680fb7..0683f1dd 100644 --- a/tests/test_subcmds.py +++ b/tests/test_subcmds.py | |||
| @@ -94,7 +94,12 @@ class AllCommands(unittest.TestCase): | |||
| 94 | """Block redundant dest= arguments.""" | 94 | """Block redundant dest= arguments.""" |
| 95 | 95 | ||
| 96 | def _check_dest(opt): | 96 | def _check_dest(opt): |
| 97 | if opt.dest is None or not opt._long_opts: | 97 | """Check the dest= setting.""" |
| 98 | # If the destination is not set, nothing to check. | ||
| 99 | # If long options are not set, then there's no implicit destination. | ||
| 100 | # If callback is used, then a destination might be needed because | ||
| 101 | # optparse cannot assume a value is always stored. | ||
| 102 | if opt.dest is None or not opt._long_opts or opt.callback: | ||
| 98 | return | 103 | return |
| 99 | 104 | ||
| 100 | long = opt._long_opts[0] | 105 | long = opt._long_opts[0] |
