From: Silvio Rhatto Date: Sun, 14 May 2017 19:42:58 +0000 (-0300) Subject: Make commit-updates work for any project we can cd into X-Git-Url: https://gitweb.fluxo.info/?a=commitdiff_plain;h=c3ad995c1ecf910e3a657293f9c8d4a614059f4f;p=utils-git.git Make commit-updates work for any project we can cd into --- diff --git a/commit-updates b/commit-updates index 082727d..ab56b2e 100755 --- a/commit-updates +++ b/commit-updates @@ -4,20 +4,25 @@ # # Parameters +PROJECT="$1" + +# Check if param is a project +if [ ! -z "$PROJECT" ] && [ -z "$2" ] && ( cd $PROJECT &> /dev/null ); then + cd $PROJECT &> /dev/null + shift +fi + +# Commit message ARGS="$*" # Simply update commit if git status &> /dev/null; then - if [ ! -z "$1" ]; then - commit "Updates $*" + if [ ! -z "$ARGS" ]; then + commit "Updates $ARGS" else commit "Updates $(basename `pwd`)" fi else - if [ ! -z "$1" ] && [ -d "$1" ]; then - ( cd $1 &> /dev/null && commit "Updates $(basename $1)" ) - else - mr commit -m "Updates" - mr fetch - fi + mr commit -m "Updates" + mr fetch fi