]> gitweb.fluxo.info Git - utils-git.git/commitdiff
Make commit-updates work for any project we can cd into
authorSilvio Rhatto <rhatto@riseup.net>
Sun, 14 May 2017 19:42:58 +0000 (16:42 -0300)
committerSilvio Rhatto <rhatto@riseup.net>
Sun, 14 May 2017 19:42:58 +0000 (16:42 -0300)
commit-updates

index 082727d1c06cdefe9aac38252207d943764c3d3f..ab56b2ed0f4ded550594a36a6c4d79a44f99ab04 100755 (executable)
@@ -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