mirror of
https://gerrit.googlesource.com/git-repo
synced 2024-12-21 07:16:21 +00:00
download: unify error handling with sub git calls
We gracefully handle cherry-pick errors, but none of the others which means people get confusing Python tracebacks. Move the main logic in a single GitError try block so we can show pretty error messages for all of them. Change-Id: I52cdf6468d21a98de7f65b86d5267b3caabd5af8 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/259854 Reviewed-by: David Pursehouse <dpursehouse@collab.net> Tested-by: Mike Frysinger <vapier@google.com>
This commit is contained in:
parent
915fda130e
commit
05097c6222
@ -109,18 +109,28 @@ If no project is specified try to use current directory as a project.
|
||||
file=sys.stderr)
|
||||
for c in dl.commits:
|
||||
print(' %s' % (c), file=sys.stderr)
|
||||
|
||||
if opt.cherrypick:
|
||||
mode = 'cherry-pick'
|
||||
elif opt.revert:
|
||||
mode = 'revert'
|
||||
elif opt.ffonly:
|
||||
mode = 'fast-forward merge'
|
||||
else:
|
||||
mode = 'checkout'
|
||||
|
||||
try:
|
||||
if opt.cherrypick:
|
||||
project._CherryPick(dl.commit, ffonly=opt.ffonly,
|
||||
record_origin=opt.record_origin)
|
||||
except GitError:
|
||||
print('[%s] Could not complete the cherry-pick of %s'
|
||||
% (project.name, dl.commit), file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
elif opt.revert:
|
||||
project._Revert(dl.commit)
|
||||
elif opt.ffonly:
|
||||
project._FastForward(dl.commit, ffonly=True)
|
||||
else:
|
||||
project._Checkout(dl.commit)
|
||||
|
||||
except GitError:
|
||||
print('[%s] Could not complete the %s of %s'
|
||||
% (project.name, mode, dl.commit), file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
Loading…
Reference in New Issue
Block a user