misc/update: add rebase option
This commit is contained in:
parent
71f44d3ac7
commit
65377655af
48
misc/update
48
misc/update
|
@ -3,7 +3,7 @@
|
|||
source ${$(realpath "$0"):h:h}/lib/common.zsh
|
||||
|
||||
ALL_ARGS=("$@")
|
||||
zparseopts -D -E -- -help=help h=help c=confs -conf=confs -skip-scripts=skip y=auto -yes=auto
|
||||
zparseopts -D -E -- -help=help h=help c=confs -conf=confs -skip-scripts=skip y=auto -yes=auto -conf-rebase=confrebase
|
||||
SCRIPTS_DIR=${$(realpath "$0"):h}
|
||||
|
||||
if [[ $help ]]; then
|
||||
|
@ -21,7 +21,12 @@ if [[ $help ]]; then
|
|||
fi
|
||||
|
||||
gitupdate() {
|
||||
git -C "$1" pull --autostash && git -C "$1" push
|
||||
zparseopts -D -E -- -conf-rebase=confrebase
|
||||
if [[ $confrebase ]]; then
|
||||
git -C "$1" pull --autostash --rebase && git -C "$1" push
|
||||
else
|
||||
git -C "$1" pull --autostash --rebase=false --ff-only && git -C "$1" push
|
||||
fi
|
||||
}
|
||||
|
||||
if [[ ! $skip ]] then
|
||||
|
@ -58,13 +63,34 @@ xbps-update () {
|
|||
fi
|
||||
}
|
||||
|
||||
misc-update() {
|
||||
for i in ${XDG_CONFIG_HOME}/update.d/*; do
|
||||
if [[ -x $i ]]; then
|
||||
info "Running updater: ${i:t}"
|
||||
$i $auto
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
config-update() {
|
||||
for confgit in ${XDG_CONFIG_HOME:-$HOME/.config}/*/.git; do
|
||||
check "Updating \"${confgit:h}\"..."
|
||||
local result=$(gitupdate "$@" "${confgit:h}" 2>&1)
|
||||
if [[ $? == 0 ]]; then
|
||||
succeed
|
||||
else
|
||||
fail "Could not update \"${confgit:h}\""
|
||||
echo $result
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
if [[ -e /etc/os-release ]]; then
|
||||
info "Updating OS... "
|
||||
source /etc/os-release
|
||||
if [[ "$ID" == void ]] || command -v xbps-install &>/dev/null; then
|
||||
info "Void Linux detected"
|
||||
xbps-update
|
||||
xbps-update $auto
|
||||
elif [[ "$ID" == ubuntu ]] || command -v apt-get &>/dev/null; then
|
||||
info "Ubuntu Linux detected"
|
||||
sudo apt-get $auto update
|
||||
|
@ -80,15 +106,9 @@ if command -v flatpak &> /dev/null; then
|
|||
fi
|
||||
|
||||
if [[ $confs ]]; then
|
||||
echo Updating configs...
|
||||
for confgit in ${XDG_CONFIG_HOME:-$HOME/.config}/*/.git; do
|
||||
check "Updating \"${confgit:h}\"..."
|
||||
local result=$(gitupdate "${confgit:h}" 2>&1)
|
||||
if [[ $? == 0 ]]; then
|
||||
succeed
|
||||
else
|
||||
fail "Could not update \"${confgit:h}\""
|
||||
echo $result
|
||||
fi
|
||||
done
|
||||
echo "Updating configs..."
|
||||
config-update $confrebase
|
||||
fi
|
||||
|
||||
echo "Running configured extra updaters..."
|
||||
misc-update $auto
|
||||
|
|
Loading…
Reference in a new issue