sync: Update sync progress even when _sync_dict is empty

By chance, _sync_dict can be empty even though repo sync is still
working. In that case, the progress message shows incorrect info. Handle this case and fix a bug where "0 jobs" can show.

Bug: http://b/284465096
Change-Id: If915d953ba60e7cf84a6fb2d137fd6ed82abd3cc
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/375494
Tested-by: Gavin Mak <gavinmak@google.com>
Reviewed-by: Josip Sokcevic <sokcevic@google.com>
Commit-Queue: Gavin Mak <gavinmak@google.com>
diff --git a/subcmds/sync.py b/subcmds/sync.py
index 0e4f34c..224d988 100644
--- a/subcmds/sync.py
+++ b/subcmds/sync.py
@@ -679,16 +679,20 @@
     def _GetSyncProgressMessage(self):
         earliest_time = float("inf")
         earliest_proj = None
-        for project, t in self._sync_dict.items():
+        items = self._sync_dict.items()
+        for project, t in items:
             if t < earliest_time:
                 earliest_time = t
                 earliest_proj = project
 
         if not earliest_proj:
-            return None
+            # This function is called when sync is still running but in some
+            # cases (by chance), _sync_dict can contain no entries. Return some
+            # text to indicate that sync is still working.
+            return "..working.."
 
         elapsed = time.time() - earliest_time
-        jobs = jobs_str(len(self._sync_dict))
+        jobs = jobs_str(len(items))
         return f"{jobs} | {elapsed_str(elapsed)} {earliest_proj}"
 
     def _Fetch(self, projects, opt, err_event, ssh_proxy):