#!/bin/bash
usage() {
    echo "Usage: ${0##*/} [-fix] work|cs|uw|personal|gmail|home|local"
    exit 2
}

fix=false

if [[ $1 = -f* ]]; then
    fix=true
    shift
elif [[ ${2-} = -f* ]]; then
    fix=true
fi

if [[ $# -ne 1 ]]; then
    usage
fi

email=

case $1 in
    w*) email=mselmeci@wisc.edu
        ;;
    cs) email=mselmeci@wisc.edu
        ;;
    uw) email=mselmeci@wisc.edu
        ;;
    p*) email=matyasbot@gmail.com
        ;;
    gm*) email=matyasbot@gmail.com
        ;;
    h*) email=matyasbot@gmail.com
        ;;
    l*) email=`whoami`@`hostname -f`
        ;;
esac

git config --local user.email $email
git config --get user.email
if $fix; then
    git commit --amend --reset-author
fi

