diff options
| author | Jason Chang <jasonnc@google.com> | 2023-08-03 14:38:00 -0700 |
|---|---|---|
| committer | LUCI <gerrit-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2023-08-07 23:56:07 +0000 |
| commit | f9aacd4087b02948da9a7878da48ea186ab99d5a (patch) | |
| tree | b683190635cd6fcb7cf817837ad0c4259b53078f /command.py | |
| parent | b8a7b4a629c3435d77a3266a4e6dce51dc342bd9 (diff) | |
| download | git-repo-f9aacd4087b02948da9a7878da48ea186ab99d5a.tar.gz | |
Raise repo exit errors in place of sys.exit
Bug: b/293344017
Change-Id: I92d81c78eba8ff31b5252415f4c9a515a6c76411
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/381774
Tested-by: Jason Chang <jasonnc@google.com>
Reviewed-by: Joanna Wang <jojwang@google.com>
Commit-Queue: Jason Chang <jasonnc@google.com>
Diffstat (limited to 'command.py')
| -rw-r--r-- | command.py | 8 |
1 files changed, 6 insertions, 2 deletions
| @@ -16,11 +16,11 @@ import multiprocessing | |||
| 16 | import os | 16 | import os |
| 17 | import optparse | 17 | import optparse |
| 18 | import re | 18 | import re |
| 19 | import sys | ||
| 20 | 19 | ||
| 21 | from event_log import EventLog | 20 | from event_log import EventLog |
| 22 | from error import NoSuchProjectError | 21 | from error import NoSuchProjectError |
| 23 | from error import InvalidProjectGroupsError | 22 | from error import InvalidProjectGroupsError |
| 23 | from error import RepoExitError | ||
| 24 | import progress | 24 | import progress |
| 25 | 25 | ||
| 26 | 26 | ||
| @@ -42,6 +42,10 @@ WORKER_BATCH_SIZE = 32 | |||
| 42 | DEFAULT_LOCAL_JOBS = min(os.cpu_count(), 8) | 42 | DEFAULT_LOCAL_JOBS = min(os.cpu_count(), 8) |
| 43 | 43 | ||
| 44 | 44 | ||
| 45 | class UsageError(RepoExitError): | ||
| 46 | """Exception thrown with invalid command usage.""" | ||
| 47 | |||
| 48 | |||
| 45 | class Command(object): | 49 | class Command(object): |
| 46 | """Base class for any command line action in repo.""" | 50 | """Base class for any command line action in repo.""" |
| 47 | 51 | ||
| @@ -215,7 +219,7 @@ class Command(object): | |||
| 215 | def Usage(self): | 219 | def Usage(self): |
| 216 | """Display usage and terminate.""" | 220 | """Display usage and terminate.""" |
| 217 | self.OptionParser.print_usage() | 221 | self.OptionParser.print_usage() |
| 218 | sys.exit(1) | 222 | raise UsageError() |
| 219 | 223 | ||
| 220 | def CommonValidateOptions(self, opt, args): | 224 | def CommonValidateOptions(self, opt, args): |
| 221 | """Validate common options.""" | 225 | """Validate common options.""" |
