build the list of commits once instead of iterating each time