[maintenance] Refactor clone

1) Refactored git clone code to be more readable
2) Moved common code of creating pack files to Pack

@devoncarew PTAL thanks.