Sync: Fix error exit code when both -n and -f are used

When repo sync is used with -f (--force-error) and a project fails to
sync, the sync will continue but then exit with an error status.

However if -n (--network-only) is also used, the exit code is 0, even
when a project failed.

Modify the logic to make sure the sync exits with the correct status.

Bug: Issue 214
Change-Id: I0b5d97a34642c5aa3743750ef14a42c9d5743c1d
This commit is contained in:
Hu Xiuyun 2015-11-25 15:52:26 +08:00 committed by David Pursehouse
parent 466b8c4ea2
commit e9becc079c

View File

@ -320,6 +320,7 @@ later is required to fix a server side protocol bug.
did_lock = True did_lock = True
if not success: if not success:
err_event.set()
print('error: Cannot fetch %s' % project.name, file=sys.stderr) print('error: Cannot fetch %s' % project.name, file=sys.stderr)
if opt.force_broken: if opt.force_broken:
print('warn: --force-broken, continuing to sync', print('warn: --force-broken, continuing to sync',
@ -330,7 +331,7 @@ later is required to fix a server side protocol bug.
fetched.add(project.gitdir) fetched.add(project.gitdir)
pm.update() pm.update()
except _FetchError: except _FetchError:
err_event.set() pass
except Exception as e: except Exception as e:
print('error: Cannot fetch %s (%s: %s)' \ print('error: Cannot fetch %s (%s: %s)' \
% (project.name, type(e).__name__, str(e)), file=sys.stderr) % (project.name, type(e).__name__, str(e)), file=sys.stderr)