File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1313# Colors
1414GREEN=' \033[0;32m'
1515BLUE=' \033[0;34m'
16+ YELLOW=' \033[1;33m'
1617RED=' \033[0;31m'
1718NC=' \033[0m'
1819
@@ -60,9 +61,24 @@ if [ -d "$INSTALL_DIR" ]; then
6061 fi
6162
6263 git fetch origin
63- git reset --hard " origin/$BRANCH "
64- git clean -fd
65- echo -e " ${GREEN} Successfully reset to origin/$BRANCH and cleaned worktree.${NC} "
64+
65+ # Prompt for confirmation before overwriting
66+ echo -e " ${YELLOW} Warning: The directory $INSTALL_DIR already contains a repository.${NC} "
67+ echo -e " ${YELLOW} Updating will perform a hard reset and discard all local changes.${NC} "
68+ # Read from /dev/tty to handle pipe execution
69+ if [ -t 0 ]; then
70+ read -p " Do you want to update and reset the repository? (y/N) " confirm
71+ else
72+ read -p " Do you want to update and reset the repository? (y/N) " confirm < /dev/tty
73+ fi
74+
75+ if [[ " $confirm " == " y" || " $confirm " == " Y" ]]; then
76+ git reset --hard " origin/$BRANCH "
77+ git clean -fd
78+ echo -e " ${GREEN} Successfully reset to origin/$BRANCH and cleaned worktree.${NC} "
79+ else
80+ echo -e " ${YELLOW} Skipping repository update. Using existing local code.${NC} "
81+ fi
6682 else
6783 # Directory exists but is NOT a git repo (e.g. manual mkdir or unzip)
6884 if [ " $( ls -A $INSTALL_DIR ) " ]; then
You can’t perform that action at this time.
0 commit comments