[PATCH v2 19/60] buildman: Move counting of commits into a function