瀏覽代碼

move update repository function to functions.sh

blezz-tech 1 天之前
父節點
當前提交
15e06423ab
共有 2 個文件被更改,包括 20 次插入20 次删除
  1. 0 20
      bin/install.sh
  2. 20 0
      bin/utils/functions.sh

+ 0 - 20
bin/install.sh

@@ -34,26 +34,6 @@ fi
 
 source bin/install.cfg
 
-# Function to check if a repository exists and perform git pull or git clone
-update_repository() {
-    local repo_url="$1"
-    local repo_dir="$2"
-    local repo_branch="$3"
-
-    if [ -d "$repo_dir" ]; then
-        # If the directory exists, then do a git pull
-        echo_warning "Updating $repo_dir..."
-        cd "$repo_dir" || exit
-        git checkout $repo_branch
-        git pull
-        cd - || exit
-    else
-        # If the directory does not exist, then do a git clone
-        echo_warning "Cloning $repo_url into $repo_dir..."
-        git clone -b "$repo_branch" "$repo_url" "$repo_dir"
-    fi
-}
-
 # Update repositories
 update_repository "$TICKETS"            "tickets"            "$TICKETS_BRANCH"
 update_repository "$BACKEND"            "dbsynce"            "$BACKEND_BRANCH"

+ 20 - 0
bin/utils/functions.sh

@@ -20,3 +20,23 @@ echo_success() {
     echo -e "${GREEN}$1${RESET}"
 }
 
+
+# Function to check if a repository exists and perform git pull or git clone
+update_repository() {
+    local repo_url="$1"
+    local repo_dir="$2"
+    local repo_branch="$3"
+
+    if [ -d "$repo_dir" ]; then
+        # If the directory exists, then do a git pull
+        echo_warning "Updating $repo_dir..."
+        cd "$repo_dir" || exit
+        git checkout $repo_branch
+        git pull
+        cd - || exit
+    else
+        # If the directory does not exist, then do a git clone
+        echo_warning "Cloning $repo_url into $repo_dir..."
+        git clone -b "$repo_branch" "$repo_url" "$repo_dir"
+    fi
+}