2020-05-19 07:35:36 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
#
|
|
|
|
# update dotbare to latest master
|
|
|
|
|
|
|
|
set -f
|
|
|
|
|
|
|
|
mydir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
|
|
|
|
|
|
function usage() {
|
|
|
|
echo -e "Usage: dotbare fupgrade [-h] ...\n"
|
2020-06-27 23:28:09 +00:00
|
|
|
echo -e "Upgrade dotbare to the latest master\n"
|
2020-05-19 07:35:36 +00:00
|
|
|
echo -e "optional arguments:"
|
2020-06-27 23:01:57 +00:00
|
|
|
echo -e " -h, --help\t\tshow this help message and exit"
|
2020-05-19 07:35:36 +00:00
|
|
|
}
|
|
|
|
|
2020-06-27 23:01:57 +00:00
|
|
|
while [[ "$#" -gt 0 ]]; do
|
|
|
|
case "$1" in
|
2020-06-27 23:28:09 +00:00
|
|
|
-h|--help)
|
2020-05-19 07:35:36 +00:00
|
|
|
usage
|
|
|
|
exit 0
|
|
|
|
;;
|
2020-06-27 23:01:57 +00:00
|
|
|
*)
|
2020-06-27 23:33:17 +00:00
|
|
|
echo "Invalid option: $1" >&2
|
2020-05-19 07:35:36 +00:00
|
|
|
usage
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
2020-06-27 23:01:57 +00:00
|
|
|
# rip from omz
|
|
|
|
# auto stash on rebase
|
|
|
|
resetAutoStash=$(git config --bool rebase.autoStash 2>&1)
|
|
|
|
git config rebase.autoStash true
|
|
|
|
|
2020-05-19 07:35:36 +00:00
|
|
|
# change directory to dotbare folder
|
|
|
|
cd "${mydir}/.."
|
2020-06-27 23:01:57 +00:00
|
|
|
|
|
|
|
echo "Updating dotbare ..."
|
|
|
|
if git pull --rebase --stat origin master; then
|
|
|
|
echo "dotbare updated successfully"
|
2020-06-27 23:21:44 +00:00
|
|
|
printf "Current dotbare version: %s\n" "$(git describe --tags $(git rev-list --tags --max-count=1))"
|
2020-06-27 23:01:57 +00:00
|
|
|
else
|
|
|
|
echo "Something went wrong, please try again or fire up a issue at https://github.com/kazhala/dotbare"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# reset autostack to original value
|
|
|
|
case "$resetAutoStash" in
|
|
|
|
"")
|
|
|
|
git config --unset rebase.autoStash
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
git config rebase.autoStash "${resetAutoStash}"
|
|
|
|
;;
|
|
|
|
esac
|