diff --git a/pull.sh b/pull.sh deleted file mode 100644 index 956d8f4c2..000000000 --- a/pull.sh +++ /dev/null @@ -1,142 +0,0 @@ -#!/bin/bash - -# Branch to process (test, preprod, master) -BRANCH=$1 - -# Retry limit for failed pull attempts -RETRY_LIMIT=3 - -# Branch types and their corresponding directories -declare -A branch_dirs=( - ["dev"]="test" - ["preprod"]="preprod" - ["master"]="master" -) - -# List of branches -branches=( - "dev_odex-event" - "dev_odex25_accounting" - "dev_odex25_base" - "dev_odex25_dms" - "dev_odex25_fleet" - "dev_odex25_helpdesk" - "dev_odex25_hr" - "dev_odex25_inventory" - "dev_odex25_maintenance" - "dev_odex25_mobile" - "dev_odex25_pos" - "dev_odex25_project" - "dev_odex25_purchase" - "dev_odex25_realstate" - "dev_odex25_sales" - "dev_odex25_survey" - "dev_odex25_transactions" - "dev_odex25_website" - "dev_openeducat_erp-14.0.1.0" - "dev_odex25_ensan" - "dev_odex25_donation" - "preprod_odex-event" - "preprod_odex25_accounting" - "preprod_odex25_base" - "preprod_odex25_dms" - "preprod_odex25_fleet" - "preprod_odex25_helpdesk" - "preprod_odex25_hr" - "preprod_odex25_inventory" - "preprod_odex25_maintenance" - "preprod_odex25_mobile" - "preprod_odex25_pos" - "preprod_odex25_project" - "preprod_odex25_purchase" - "preprod_odex25_realstate" - "preprod_odex25_sales" - "preprod_odex25_survey" - "preprod_odex25_transactions" - "preprod_odex25_website" - "preprod_openeducat_erp-14.0.1.0" - "preprod_odex25_ensan" - "preprod_odex25_donation" - "master_odex-event" - "master_odex25_accounting" - "master_odex25_base" - "master_odex25_dms" - "master_odex25_fleet" - "master_odex25_helpdesk" - "master_odex25_hr" - "master_odex25_inventory" - "master_odex25_maintenance" - "master_odex25_mobile" - "master_odex25_pos" - "master_odex25_project" - "master_odex25_purchase" - "master_odex25_realstate" - "master_odex25_sales" - "master_odex25_survey" - "master_odex25_transactions" - "master_odex25_website" - "master_openeducat_erp-14.0.1.0" - "master_odex25_ensan" - "master_odex25_donation" -) - -# Error log file -error_log="pull_error_log.txt" > "$error_log" # Clear log file at the start - -# Function to pull code with retries -pull_branch() { - local branch=$1 - local full_path=$2 - local attempt=1 - - while [ $attempt -le $RETRY_LIMIT ]; do - echo "Pulling $branch into $full_path (Attempt $attempt/$RETRY_LIMIT)..." - - # Navigate to the directory and pull the latest changes - cd "$full_path" || { echo "Failed to access $full_path"; exit 1; } - git pull origin "$branch" - local pull_status=$? - - # Return to the previous directory - cd - || exit 1 - - if [ $pull_status -eq 0 ]; then - echo "Successfully pulled $branch into $full_path" - return 0 - else - echo "Failed to pull $branch (Attempt $attempt)." - attempt=$((attempt + 1)) - fi - done - - # If retry limit is reached, log the failure - echo "Failed to pull $branch after $RETRY_LIMIT attempts." >> "$error_log" - return 1 -} - -# Loop through each branch -for branch in "${branches[@]}"; do - prefix="${branch%%_*}" - - # Check if the branch matches the input and the prefix is valid - if [ "$BRANCH" == "${branch_dirs[$prefix]}" ]; then - folder_name="${branch#*_}" - full_path="$BRANCH/$folder_name" - - # Skip the branch if the directory does not exist - if [ ! -d "$full_path" ]; then - echo "Skipping $branch: $full_path does not exist" - continue - fi - - # Pull the branch with error handling - pull_branch "$branch" "$full_path" - fi -done - -# Check if any errors were logged -if [ -s "$error_log" ]; then - echo "Some branches failed to pull. Check $error_log for details." -else - echo "All branches pulled successfully." -fi