Reduce duplicated code by adding a function to create repo list items.

Minor changes to reduce duplicated code and increase readability.