#!/bin/bash
# Description: The Git version control system
set -e

GIT_NAME="Correl Roush"
GIT_EMAIL="correl@gmail.com"

case $_PLATFORM in
    darwin)
        _recipe brew
        _brew git
        ;;
    arch)
        _recipe _arch
        _pacman git
        ;;
    debian)
        _recipe _apt
        _ppa git-core/ppa
        _apt git
        ;;
esac

function _git {
    local repo=$1
    local dest=$2
    if ! test -d "$dest"; then
        _run "[git] Clone $repo to $dest" git clone --recursive $1 $2
    else
        echo "[git] $dest already exists, skipping."
    fi
}

git config --global user.email >/dev/null || _run "[git] Setting user.email to '$GIT_EMAIL'" git config --global user.email $GIT_EMAIL
git config --global user.name >/dev/null || _run "[git] Setting user.name to '$GIT_NAME'" git config --global user.name $GIT_NAME