feat: Improve bootstrap script to handle existing directories and cloning logic

This commit is contained in:
Peter Wood
2025-11-29 09:37:00 -05:00
parent 8ceeeda560
commit 40cbecdebf

View File

@@ -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"