factor repo handling from Opam_task