Show update prompt when running bash-it update

This utilizes the body of the merged PR requests to show the commits
that are included in this update. It gives the user a chance to
decline the upgrades by pressing n or N.
pull/1280/head
Travis Swicegood 2018-12-02 10:16:33 -06:00
parent e3a89c8ef1
commit 8e7a566d96
1 changed files with 25 additions and 12 deletions

View File

@ -181,6 +181,11 @@ _bash-it_update() {
status="$(git rev-list master..${BASH_IT_REMOTE}/master 2> /dev/null)" status="$(git rev-list master..${BASH_IT_REMOTE}/master 2> /dev/null)"
if [[ -n "${status}" ]]; then if [[ -n "${status}" ]]; then
git log --merges --format="%h: %b (%an)" master..${BASH_IT_REMOTE}/master
echo ""
read -e -n 1 -p "Would you like to update to $(git log -1 --format=%h origin/master)? [Y/n] " RESP
case $RESP in
[yY]|"")
git pull --rebase &> /dev/null git pull --rebase &> /dev/null
if [[ $? -eq 0 ]]; then if [[ $? -eq 0 ]]; then
echo "Bash-it successfully updated." echo "Bash-it successfully updated."
@ -193,6 +198,14 @@ _bash-it_update() {
else else
echo "Error updating Bash-it, please, check if your Bash-it installation folder (${BASH_IT}) is clean." echo "Error updating Bash-it, please, check if your Bash-it installation folder (${BASH_IT}) is clean."
fi fi
;;
[nN])
echo "Not upgrading…"
;;
*)
echo -e "\033[91mPlease choose y or n.\033[m"
;;
esac
else else
echo "Bash-it is up to date, nothing to do!" echo "Bash-it is up to date, nothing to do!"
fi fi