diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2024-07-30 20:57:31 -0300 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2024-07-30 20:57:31 -0300 |
commit | 70e9e4d42b8a344c4a68cf4bd1c7921df3067853 (patch) | |
tree | 47813b183e6ab53cb6d8fd1611dc2882c251672e /rsup | |
parent | a224277c6bb2b3c9d4dfbd5283f3a3d4ec991e4d (diff) | |
download | utils-git-70e9e4d42b8a344c4a68cf4bd1c7921df3067853.tar.gz utils-git-70e9e4d42b8a344c4a68cf4bd1c7921df3067853.tar.bz2 |
Fix: rsup enhancements
Diffstat (limited to 'rsup')
-rwxr-xr-x | rsup | 59 |
1 files changed, 54 insertions, 5 deletions
@@ -14,6 +14,46 @@ BASENAME="`basename $0`" MESSAGE="$*" GIT="hit" +# Commit upwards +function upward_commit { + local level="" + local up="../" + local found="0" + local base + local log + local message + + # Check upwards if there's a .git folder + while true; do + # Stop on the root folder + if [ "`cd $level &> /dev/null && pwd`" == "/" ]; then + break + fi + + if [ -d "$level/.git" ]; then + found="1" + break + fi + + level="${level}${up}" + done + + # Commit in the parent repository + if [ "$found" == "1" ]; then + base="$(basename `pwd`)" + log="`git log -1 --oneline`" + message="Updates $BASE: $LOG" + + ( cd .. &> /dev/null && $GIT add -f $base ) + + cd $level && $DIRNAME/commit "$message" + + return 0 + fi + + return 1 +} + # Check if it is a git repository if [ ! -d ".git" ]; then echo "$BASENAME: not a git repository" @@ -27,10 +67,19 @@ if [ -z "$MESSAGE" ]; then fi # Commit -commit $MESSAGE +$DIRNAME/commit $MESSAGE + +# Commit upwards until there are repositories +while true; do + # Stop on the root folder + if [ "`pwd`" == "/" ]; then + break + fi -# Go up -while test -d "../.git"; do - sup - cd .. + # Go up + if upward_commit; then + cd .. + else + break + fi done |