Extract repository looping into separate function

This prepares for the upcoming split of the commit and push step into
two separate steps, as otherwise this split would lead to a thrid loop
over the same set of repos.

Change-Id: If776f4e0f03727a824c7a0bb33bf81c1879a2332