Add an option to "sync" = "stash; pull --rebase; push; pop stash"

This commit is contained in:
Adam Goldsmith 2019-01-15 21:46:37 -05:00
parent a369e45d8d
commit c5ded1e9f7

19
dup
View File

@ -20,6 +20,16 @@ function do_get() {
fi fi
} }
function do_pull() {
if [ "$stashAndSync" = true ]
then
git stash
git pull --rebase
git push
git stash pop || true
fi
}
function run_script() { function run_script() {
script="$1"; shift script="$1"; shift
targets="$@" targets="$@"
@ -45,6 +55,7 @@ function maybe_stow() {
stow=true stow=true
bootstrap=false bootstrap=false
stashAndSync=false
while [ "$#" -gt 0 ] while [ "$#" -gt 0 ]
do do
case $1 in case $1 in
@ -56,6 +67,10 @@ do
bootstrap=true bootstrap=true
shift shift
;; ;;
-s | --stash-and-sync)
stashAndSync=true
shift
;;
--) --)
shift shift
break break
@ -90,13 +105,13 @@ then
elif [ "$bootstrap" != true ] elif [ "$bootstrap" != true ]
then then
echo "Updating .dotfiles" echo "Updating .dotfiles"
git pull do_pull
for dir in */ for dir in */
do do
echo "Updating $dir" echo "Updating $dir"
cd "$dir" cd "$dir"
git pull do_pull
cd .. cd ..
done done