Display globalrefdb check progress over SSH

Display some percentage progress and ETA when checking
the project's refs consistency with the globalrefdb.

This is mainly done for preventing the SSH channel to
exit for timeout.

Change-Id: Ic053b6d669255f598d30d445b7b8a5a47f871e62
diff --git a/multi-primary/globalrefdb.groovy b/multi-primary/globalrefdb.groovy
index b47cdb8..1530f9b 100644
--- a/multi-primary/globalrefdb.groovy
+++ b/multi-primary/globalrefdb.groovy
@@ -77,8 +77,21 @@
           upToDate = checkRef(projectName, repo, ref)
         } else {
           println "Checking project $project ..."
+          def totRefs = repo.refDatabase.refs.size()
+          def refsDone = 0
+          def refsDonePerc = 0
+          def startTime = System.currentTimeMillis()
           repo.refDatabase.refs.each { ref ->
             checkRef(projectName, repo, ref)
+            if (!verbose) {
+              refsDone++
+              if ((refsDone * 100).intdiv(totRefs) > refsDonePerc) {
+                refsDonePerc = (refsDone * 100).intdiv(totRefs)
+                def totTime = startTime + Math.round((System.currentTimeMillis() - startTime) / refsDonePerc * 100)
+                def eta = Math.round((totTime - System.currentTimeMillis()) / 1000)
+                println "  $refsDone/$totRefs ($refsDonePerc%, ETA $eta sec)"
+              }
+            }
           }
         }