Abstract git detection logic