diff options
| author | Jason Chang <jasonnc@google.com> | 2023-08-08 14:12:53 -0700 |
|---|---|---|
| committer | LUCI <gerrit-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2023-08-10 23:46:31 +0000 |
| commit | 1a3612fe6d347e458a53d7a9e920a91ea502e6ba (patch) | |
| tree | 02b1a61f1d97e32201ea5fa309bf1f1b6050e929 /subcmds/selfupdate.py | |
| parent | f0aeb220def22edfac9838288ad251f86da782c1 (diff) | |
| download | git-repo-1a3612fe6d347e458a53d7a9e920a91ea502e6ba.tar.gz | |
Raise RepoExitError in place of sys.exit
Bug: b/293344017
Change-Id: Icae4932b00e4068cba502a5ab4a0274fd7854d9d
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/382214
Reviewed-by: Gavin Mak <gavinmak@google.com>
Tested-by: Jason Chang <jasonnc@google.com>
Reviewed-by: Aravind Vasudevan <aravindvasudev@google.com>
Commit-Queue: Jason Chang <jasonnc@google.com>
Diffstat (limited to 'subcmds/selfupdate.py')
| -rw-r--r-- | subcmds/selfupdate.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/subcmds/selfupdate.py b/subcmds/selfupdate.py index d5d0a838..00376b66 100644 --- a/subcmds/selfupdate.py +++ b/subcmds/selfupdate.py | |||
| @@ -18,6 +18,11 @@ import sys | |||
| 18 | from command import Command, MirrorSafeCommand | 18 | from command import Command, MirrorSafeCommand |
| 19 | from subcmds.sync import _PostRepoUpgrade | 19 | from subcmds.sync import _PostRepoUpgrade |
| 20 | from subcmds.sync import _PostRepoFetch | 20 | from subcmds.sync import _PostRepoFetch |
| 21 | from error import RepoExitError | ||
| 22 | |||
| 23 | |||
| 24 | class SelfupdateError(RepoExitError): | ||
| 25 | """Exit error for failed selfupdate command.""" | ||
| 21 | 26 | ||
| 22 | 27 | ||
| 23 | class Selfupdate(Command, MirrorSafeCommand): | 28 | class Selfupdate(Command, MirrorSafeCommand): |
| @@ -58,9 +63,10 @@ need to be performed by an end-user. | |||
| 58 | _PostRepoUpgrade(self.manifest) | 63 | _PostRepoUpgrade(self.manifest) |
| 59 | 64 | ||
| 60 | else: | 65 | else: |
| 61 | if not rp.Sync_NetworkHalf().success: | 66 | result = rp.Sync_NetworkHalf() |
| 67 | if result.error: | ||
| 62 | print("error: can't update repo", file=sys.stderr) | 68 | print("error: can't update repo", file=sys.stderr) |
| 63 | sys.exit(1) | 69 | raise SelfupdateError(aggregate_errors=[result.error]) |
| 64 | 70 | ||
| 65 | rp.bare_git.gc("--auto") | 71 | rp.bare_git.gc("--auto") |
| 66 | _PostRepoFetch(rp, repo_verify=opt.repo_verify, verbose=True) | 72 | _PostRepoFetch(rp, repo_verify=opt.repo_verify, verbose=True) |
