From 802cd0c6016d91c62c25178ee1ccc1e78505502c Mon Sep 17 00:00:00 2001 From: Karsten Tausche Date: Tue, 6 Dec 2022 09:56:28 +0100 Subject: [PATCH] sync: Fix undefined variable in _FetchOne If syncing in _FetchOne fails with GitError, sync_result does not get set. There's already a separate local variable for success; do the same for remote_fetched instead of referring to the conditionally defined named tuple. This bug is originally caused by a combination of ad8aa697 "sync: only print error.GitError, don't raise that exception." and 1eddca84 "sync: use namedtuples for internal return values". Change-Id: I0f9dbafb97f8268044e5a56a6f92cf29bc23ca6a Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/354176 Tested-by: Karsten Tausche Reviewed-by: LaMont Jones --- subcmds/sync.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/subcmds/sync.py b/subcmds/sync.py index 7cf303b3..0c0f0cf3 100644 --- a/subcmds/sync.py +++ b/subcmds/sync.py @@ -470,6 +470,7 @@ later is required to fix a server side protocol bug. """ start = time.time() success = False + remote_fetched = False buf = io.StringIO() try: sync_result = project.Sync_NetworkHalf( @@ -487,6 +488,7 @@ later is required to fix a server side protocol bug. clone_filter=project.manifest.CloneFilter, partial_clone_exclude=project.manifest.PartialCloneExclude) success = sync_result.success + remote_fetched = sync_result.remote_fetched output = buf.getvalue() if (opt.verbose or not success) and output: @@ -504,8 +506,7 @@ later is required to fix a server side protocol bug. raise finish = time.time() - return _FetchOneResult(success, project, start, finish, - sync_result.remote_fetched) + return _FetchOneResult(success, project, start, finish, remote_fetched) @classmethod def _FetchInitChild(cls, ssh_proxy):