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
|
source ${$(realpath "$0"):h:h}/lib/common.zsh
|
||||||
|
|
||||||
ALL_ARGS=("$@")
|
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}
|
SCRIPTS_DIR=${$(realpath "$0"):h}
|
||||||
|
|
||||||
if [[ $help ]]; then
|
if [[ $help ]]; then
|
||||||
|
@ -21,7 +21,12 @@ if [[ $help ]]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
gitupdate() {
|
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
|
if [[ ! $skip ]] then
|
||||||
|
@ -58,13 +63,34 @@ xbps-update () {
|
||||||
fi
|
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
|
if [[ -e /etc/os-release ]]; then
|
||||||
info "Updating OS... "
|
info "Updating OS... "
|
||||||
source /etc/os-release
|
source /etc/os-release
|
||||||
if [[ "$ID" == void ]] || command -v xbps-install &>/dev/null; then
|
if [[ "$ID" == void ]] || command -v xbps-install &>/dev/null; then
|
||||||
info "Void Linux detected"
|
info "Void Linux detected"
|
||||||
xbps-update
|
xbps-update $auto
|
||||||
elif [[ "$ID" == ubuntu ]] || command -v apt-get &>/dev/null; then
|
elif [[ "$ID" == ubuntu ]] || command -v apt-get &>/dev/null; then
|
||||||
info "Ubuntu Linux detected"
|
info "Ubuntu Linux detected"
|
||||||
sudo apt-get $auto update
|
sudo apt-get $auto update
|
||||||
|
@ -80,15 +106,9 @@ if command -v flatpak &> /dev/null; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $confs ]]; then
|
if [[ $confs ]]; then
|
||||||
echo Updating configs...
|
echo "Updating configs..."
|
||||||
for confgit in ${XDG_CONFIG_HOME:-$HOME/.config}/*/.git; do
|
config-update $confrebase
|
||||||
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
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
echo "Running configured extra updaters..."
|
||||||
|
misc-update $auto
|
||||||
|
|
Loading…
Reference in a new issue