74 lines
2.4 KiB
Bash
74 lines
2.4 KiB
Bash
#!/bin/bash
|
|
|
|
# Define color variables
|
|
YELLOW='\e[33m'
|
|
GREEN='\e[32m'
|
|
CYAN='\e[36m'
|
|
RED='\e[31m'
|
|
NC='\e[0m' # No Color
|
|
|
|
# Introduce program to user with echo
|
|
echo -e "${CYAN}-----------------------------------${NC}"
|
|
echo -e "${CYAN}- AllSpice + SVN clone${NC}"
|
|
echo -e "${CYAN}-----------------------------------${NC}"
|
|
echo " "
|
|
|
|
# Prompt user for ALLSPICE_URL
|
|
echo -e "${YELLOW}- Enter the AllSpice URL:${NC}"
|
|
read ALLSPICE_URL
|
|
|
|
# Prompt user for SVN_URL
|
|
echo -e "${YELLOW}- Enter the SVN URL:${NC}"
|
|
read SVN_URL
|
|
|
|
# Debug, if ALLSPICE_URL is empty, set to default
|
|
if [ -z "$ALLSPICE_URL" ]; then
|
|
ALLSPICE_URL="https://staging.allspice.dev/chaos_engineering/Git-Loves-SVN.git"
|
|
echo -e "${RED}- No URL provided, using default: $ALLSPICE_URL${NC}"
|
|
fi
|
|
|
|
# Debug, if SVN_URL is empty, set to default
|
|
if [ -z "$SVN_URL" ]; then
|
|
SVN_URL="https://floorputer/svn/Vanilla-1/"
|
|
echo -e "${RED}- No URL provided, using default: $SVN_URL${NC}"
|
|
fi
|
|
|
|
echo " "
|
|
echo -e "${CYAN}- Cloning the AllSpice repository...${NC}"
|
|
echo -e "${GREEN}- git clone $ALLSPICE_URL${NC}"
|
|
git clone $ALLSPICE_URL
|
|
|
|
# Extract repository name from ALLSPICE_URL
|
|
REPO_NAME=$(echo $ALLSPICE_URL | awk -F'/' '{print $NF}' | sed 's/.git//')
|
|
|
|
echo " "
|
|
echo -e "${CYAN}- Cloning the SVN repository...${NC}"
|
|
echo -e "${GREEN}- git svn clone -r HEAD $SVN_URL --stdlayout $USERPROFILE/allspice/$REPO_NAME${NC}"
|
|
git svn clone -r HEAD $SVN_URL --stdlayout $USERPROFILE/allspice/$REPO_NAME
|
|
|
|
cd $USERPROFILE/allspice/$REPO_NAME
|
|
|
|
echo " "
|
|
echo -e "${CYAN}-----------------------------------${NC}"
|
|
echo -e "${CYAN}- Syncing SVN trunk with AllSpice main branch...${NC}"
|
|
git checkout trunk
|
|
git checkout main
|
|
git reset --hard trunk
|
|
git push --force origin main
|
|
git checkout trunk
|
|
echo -e "${CYAN}-----------------------------------${NC}"
|
|
|
|
# Download pre-push hook
|
|
echo -e "${YELLOW}- Downloading pre-push hook...${NC}"
|
|
curl -L -o $USERPROFILE/allspice/$REPO_NAME/.git/hooks/pre-push https://hub.allspice.io/AllSpice-Demos/AllSpice-Loves-SVN/raw/branch/main/.allspice/pre-push
|
|
chmod +x $USERPROFILE/allspice/$REPO_NAME/.git/hooks/pre-push
|
|
|
|
# Download fetch-svn.bat
|
|
echo -e "${YELLOW}- Downloading fetch-svn.bat...${NC}"
|
|
curl -L -o $USERPROFILE/allspice/$REPO_NAME/fetch-svn.bat https://hub.allspice.io/AllSpice-Demos/AllSpice-Loves-SVN/raw/branch/main/.allspice/fetch-svn.bat
|
|
|
|
echo -e "${GREEN}- Done!${NC}"
|
|
echo -e "${CYAN}-----------------------------------${NC}"
|
|
|
|
echo "*.bat" >> .gitignore && sort -u -o .gitignore .gitignore
|