Skip to content

Commit 1a60c1e

Browse files
committed
feat: move update confirmation before git fetch
1 parent 2b2c1dd commit 1a60c1e

1 file changed

Lines changed: 8 additions & 13 deletions

File tree

download-and-install.sh

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -60,24 +60,19 @@ if [ -d "$INSTALL_DIR" ]; then
6060
fi
6161
fi
6262

63-
git fetch origin
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
63+
# Prompt for confirmation BEFORE any git operations
64+
echo -e "${YELLOW}Existing repository detected at $INSTALL_DIR.${NC}"
65+
echo -e "${YELLOW}Would you like to fetch and reset to latest origin/$BRANCH? (y/N)${NC}"
66+
read -p "> " confirm < /dev/tty
7467

7568
if [[ "$confirm" == "y" || "$confirm" == "Y" ]]; then
69+
echo -e "${BLUE}Updating repository...${NC}"
70+
git fetch origin
7671
git reset --hard "origin/$BRANCH"
7772
git clean -fd
78-
echo -e "${GREEN}Successfully reset to origin/$BRANCH and cleaned worktree.${NC}"
73+
echo -e "${GREEN}Successfully updated and cleaned worktree.${NC}"
7974
else
80-
echo -e "${YELLOW}Skipping repository update. Using existing local code.${NC}"
75+
echo -e "${BLUE}Skipping update. Using existing local code.${NC}"
8176
fi
8277
else
8378
# Directory exists but is NOT a git repo (e.g. manual mkdir or unzip)

0 commit comments

Comments
 (0)