mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-04-10 04:26:17 +02:00
prompt user if repo has changes before upgrading
This commit is contained in:
parent
686e460258
commit
d1f769b147
1 changed files with 34 additions and 5 deletions
|
|
@ -20,10 +20,7 @@ else
|
|||
NORMAL=""
|
||||
fi
|
||||
|
||||
printf "${BLUE}%s${NORMAL}\n" "Updating Oh My Zsh"
|
||||
cd "$ZSH"
|
||||
if git pull --rebase --stat origin master
|
||||
then
|
||||
success_upgrading() {
|
||||
printf '%s' "$GREEN"
|
||||
printf '%s\n' ' __ __ '
|
||||
printf '%s\n' ' ____ / /_ ____ ___ __ __ ____ _____/ /_ '
|
||||
|
|
@ -34,6 +31,38 @@ then
|
|||
printf "${BLUE}%s\n" "Hooray! Oh My Zsh has been updated and/or is at the current version."
|
||||
printf "${BLUE}${BOLD}%s${NORMAL}\n" "To keep up on the latest news and updates, follow us on twitter: https://twitter.com/ohmyzsh"
|
||||
printf "${BLUE}${BOLD}%s${NORMAL}\n" "Get your Oh My Zsh swag at: http://shop.planetargon.com/"
|
||||
else
|
||||
exit 0
|
||||
}
|
||||
|
||||
error_upgrading() {
|
||||
printf "${RED}%s${NORMAL}\n" 'There was an error updating. Try again later?'
|
||||
exit 1
|
||||
}
|
||||
|
||||
run_upgrade() {
|
||||
if git pull --rebase --stat origin master
|
||||
then
|
||||
success_updating
|
||||
else
|
||||
error_updating
|
||||
fi
|
||||
}
|
||||
|
||||
printf "${BLUE}%s${NORMAL}\n" "Updating Oh My Zsh"
|
||||
cd "$ZSH"
|
||||
|
||||
if output=$(git status --porcelain); then
|
||||
while true; do
|
||||
printf "${RED}%s${NORMAL}\n" "You have changes that are preventing Oh My Zsh from upgrading."
|
||||
printf "${RED}%s${NORMAL}" "Do you want to stash these changes and continue? "
|
||||
read -p "" answer
|
||||
case $answer in
|
||||
[Yy]* ) git stash; run_update;;
|
||||
[Nn]* ) exit;;
|
||||
* ) echo "Please answer yes or no.";;
|
||||
esac
|
||||
done
|
||||
else
|
||||
run_update
|
||||
fi
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue