2020-05-20 18:34:34 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
######################################################################
|
2020-05-23 15:47:21 +02:00
|
|
|
# @author : swytch
|
|
|
|
# @file : dot
|
2020-06-25 18:19:40 +02:00
|
|
|
# @license : MIT
|
2020-05-23 15:47:21 +02:00
|
|
|
# @created : Wednesday May 20, 2020 18:13:05 CEST
|
2020-05-20 18:34:34 +02:00
|
|
|
#
|
2020-05-23 15:47:21 +02:00
|
|
|
# @description : git wrapper for dotfiles management
|
2020-05-20 18:34:34 +02:00
|
|
|
######################################################################
|
2020-05-06 03:20:19 +02:00
|
|
|
|
2020-11-12 19:08:37 +01:00
|
|
|
flags="false"
|
|
|
|
for arg in $@
|
|
|
|
do
|
|
|
|
case $arg in
|
2021-01-13 00:47:39 +01:00
|
|
|
--*) ;;
|
2020-11-12 19:08:37 +01:00
|
|
|
-*) [ "$flags" = "true" ] && flags="error" && break || flags="true" ;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
|
|
|
[ "$flags" = "error" ] && echo "error: only one flag permitted" && exit 1
|
2020-05-06 03:20:19 +02:00
|
|
|
|
|
|
|
git="/usr/bin/git --git-dir=$HOME/.dotfiles --work-tree=$HOME"
|
|
|
|
|
2020-11-12 18:03:45 +01:00
|
|
|
case $1 in
|
|
|
|
-*)
|
2020-11-12 19:08:37 +01:00
|
|
|
[ "$1" = "-l" ] && cmd="$git log" && break
|
|
|
|
[ "$1" = "-lg" ] && cmd="$git log --graph --format=short" && break
|
|
|
|
[ "$1" = "-c" ] && shift && cmd="$git commit $@" && break
|
|
|
|
[ "$1" = "-ca" ] && cmd="$git commit -a" && break
|
|
|
|
[ "$1" = "-cas" ] && shift && cmd="$git commit -S --amend $@" && break
|
|
|
|
[ "$1" = "-ch" ] && shift && cmd="$git checkout $@" && break
|
|
|
|
[ "$1" = "-mv" ] && shift && cmd="$git mv $@" && break
|
|
|
|
[ "$1" = "-ps" ] && shift && cmd="$git push $@" && break
|
|
|
|
[ "$1" = "-pl" ] && cmd="$git pull" && break
|
|
|
|
[ "$1" = "-a" ] && shift && cmd="$git add $@" && break
|
|
|
|
[ "$1" = "-b" ] && shift && cmd="$git branch $@" && break
|
|
|
|
[ "$1" = "-s" ] && shift && cmd="$git show $@" && break
|
|
|
|
[ "$1" = "-rm" ] && shift && cmd="$git rm --cached $@" && break
|
|
|
|
[ "$1" = "-rb" ] && shift && cmd="$git rebase $@" && break
|
|
|
|
[ "$1" = "-rbi" ] && shift && cmd="$git rebase -i $@" && break
|
|
|
|
[ "$1" = "-rs" ] && shift && cmd="$git reset --soft $@" && break
|
|
|
|
[ "$1" = "-d" ] && shift && cmd="$git diff $@" && break
|
2020-11-12 18:03:45 +01:00
|
|
|
if [ "$1" = "-m" ] ; then
|
2020-05-06 03:20:19 +02:00
|
|
|
shift
|
2021-01-13 00:47:39 +01:00
|
|
|
[ "$1" = "" ] && echo "Please provide a branche to merge into" && exit 1
|
2020-11-12 18:03:45 +01:00
|
|
|
if [ "$1" != "-a" ] ; then
|
|
|
|
while [ "$1" != "" ] ; do
|
|
|
|
$git checkout $1 && $git merge dev
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
else
|
|
|
|
branches="$(echo "$($git branch)" | sed -e 's/\*/ /;t')"
|
|
|
|
for arg in $branches ; do
|
2020-11-12 19:08:01 +01:00
|
|
|
[ "$arg" != "dev" ] && $git checkout $arg && $git merge dev
|
2020-11-12 18:03:45 +01:00
|
|
|
done
|
2020-05-06 03:20:19 +02:00
|
|
|
fi
|
2020-11-12 18:03:45 +01:00
|
|
|
cmd="$git checkout dev"
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
[ "$1" != "" ] && cmd="$git $@" || cmd="$git status"
|
|
|
|
;;
|
|
|
|
esac
|
2020-05-06 03:20:19 +02:00
|
|
|
|
|
|
|
$cmd
|