summaryrefslogtreecommitdiff
path: root/scripts/installation.sh
diff options
context:
space:
mode:
author魏曹先生 <1992414357@qq.com>2025-11-10 10:08:33 +0800
committer魏曹先生 <1992414357@qq.com>2025-11-10 10:08:33 +0800
commit490e3f9aaff5667be380b4ce106ffd4f96c61612 (patch)
treef359254c2f5d55ffaba366c532077d606206f0b4 /scripts/installation.sh
parentb4314aaeb35c3af32e8ad72d6cb86ed554897850 (diff)
Improve installation script to handle existing repositories
The script now checks if repositories already exist and pulls latest changes instead of attempting to clone again. This prevents errors when re-running the installation script and ensures users always get the latest code.
Diffstat (limited to 'scripts/installation.sh')
-rw-r--r--scripts/installation.sh26
1 files changed, 22 insertions, 4 deletions
diff --git a/scripts/installation.sh b/scripts/installation.sh
index c109301..5e853b6 100644
--- a/scripts/installation.sh
+++ b/scripts/installation.sh
@@ -13,12 +13,30 @@ fi
echo "Installation directory set to current directory: $(pwd)"
install_dir="$(pwd)"
-# Clone repos
-echo "Cloning repositories..."
+# Clone or update repos
+echo "Cloning or updating repositories..."
mkdir -p "$install_dir"
cd "$install_dir"
-git clone https://github.com/JustEnoughVCS/CommandLine
-git clone https://github.com/JustEnoughVCS/VersionControl
+
+# Function to clone or pull repository
+clone_or_pull() {
+ local repo_url="$1"
+ local repo_name=$(basename "$repo_url")
+
+ if [ -d "$repo_name" ]; then
+ echo "Repository $repo_name already exists, pulling latest changes..."
+ cd "$repo_name"
+ git pull origin main
+ cd ..
+ else
+ echo "Cloning $repo_name..."
+ git clone "$repo_url"
+ fi
+}
+
+# Clone or update repositories
+clone_or_pull https://github.com/JustEnoughVCS/CommandLine
+clone_or_pull https://github.com/JustEnoughVCS/VersionControl
# Setup VersionControl repo
echo "Setting up VersionControl..."