Factor out generic repo logic into own repo