From 40cbecdebfe8ee86c6d69f8bc3d9d4026ed236c8 Mon Sep 17 00:00:00 2001 From: Peter Wood Date: Sat, 29 Nov 2025 09:37:00 -0500 Subject: [PATCH] feat: Improve bootstrap script to handle existing directories and cloning logic --- setup/bootstrap.sh | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/setup/bootstrap.sh b/setup/bootstrap.sh index 5326115..388ec6d 100755 --- a/setup/bootstrap.sh +++ b/setup/bootstrap.sh @@ -61,14 +61,24 @@ if ! command -v git &>/dev/null; then esac fi -# Create shell directory if it doesn't exist -mkdir -p "$HOME/shell" - # Clone or update repository -if [ -d "$DOTFILES_DIR" ]; then +if [ -d "$DOTFILES_DIR/.git" ]; then echo -e "${YELLOW}Updating existing shell repository...${NC}" cd "$DOTFILES_DIR" git pull origin $DOTFILES_BRANCH +elif [ -d "$DOTFILES_DIR" ]; then + echo -e "${YELLOW}Directory exists but is not a git repository.${NC}" + # Check if directory is empty + if [ -z "$(ls -A "$DOTFILES_DIR")" ]; then + echo -e "${YELLOW}Directory is empty. Cloning...${NC}" + git clone "https://github.com/$DOTFILES_REPO.git" "$DOTFILES_DIR" + else + echo -e "${YELLOW}Backing up existing directory...${NC}" + mv "$DOTFILES_DIR" "${DOTFILES_DIR}.bak.$(date +%s)" + echo -e "${YELLOW}Cloning shell repository...${NC}" + git clone "https://github.com/$DOTFILES_REPO.git" "$DOTFILES_DIR" + fi + cd "$DOTFILES_DIR" else echo -e "${YELLOW}Cloning shell repository...${NC}" git clone "https://github.com/$DOTFILES_REPO.git" "$DOTFILES_DIR"