parse_repository_tag function and accompanying test

Same as  #177, but rebased.