Changeset 3372214
- Timestamp:
- 10/03/2025 08:43:35 AM (6 months ago)
- File:
-
- 1 edited
-
pagbank-for-woocommerce/batch-commit.sh (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
pagbank-for-woocommerce/batch-commit.sh
r3295464 r3372214 1 1 #!/bin/bash 2 2 VERSION="$1" 3 BATCH_SIZE="${2:-500}"4 3 5 4 if [ -z "$VERSION" ]; then 6 echo "Usage: $0 <version> [batch_size]"7 exit 15 echo "Usage: $0 <version>" 6 exit 1 8 7 fi 9 8 10 # Create all directories in SVN first (without files) 11 # This ensures the directory structure exists in the repository before adding files 12 echo -e "\033[1;34mCreating directory structure...\033[0m" 13 find "tags/$VERSION" -type d | sort | while read dir; do 14 svn mkdir --parents "$dir" 2>/dev/null || true 9 # add the whole folder 10 # svn add "tags/$VERSION" 11 12 # revert the vendor folder 13 # svn revert "tags/$VERSION/vendor" --depth infinity 14 15 # add vendor/autoload.php explicitly 16 # svn add "tags/$VERSION/vendor/autoload.php" 17 18 # # commit the first part 19 # echo "Committing source code for version $VERSION..." 20 # svn commit -m "add version $VERSION source code" 21 22 # list folders 23 folders=(tags/$VERSION/vendor/*/) 24 folders=("${folders[@]}") 25 total=0 26 for d in "${folders[@]}"; do 27 [ "$(basename "$d")" != "bin" ] && ((total++)) 15 28 done 16 29 17 # Initial commit of directories only 18 # This commits the directory structure to the repository 19 echo -e "\033[1;34mCommitting directory structure...\033[0m" 20 svn ci -m "create directory structure for $VERSION" "tags/$VERSION" 30 count=0 31 for d in "${folders[@]}"; do 32 if [ "$(basename "$d")" != "bin" ]; then 33 ((count++)) 34 echo "[$count/$total] Committing vendor folder $(basename "$d") for version $VERSION..." 35 svn add "$d" 36 svn commit -m "add vendor folder $(basename "$d") for version $VERSION" 37 fi 38 done 21 39 22 # Generate ordered list of files (excluding .DS_Store) 23 # This prepares the list of files to be added and committed in batches 24 FILES=$(find "tags/$VERSION" -type f -not -name ".DS_Store" | sort) 25 TOTAL=$(echo "$FILES" | wc -l) 26 NUM_PARTS=$(( (TOTAL + BATCH_SIZE - 1) / BATCH_SIZE )) 27 PART=1 28 29 # Split the list of files into batches 30 # Each batch will be processed separately to avoid timeouts 31 TMP_PREFIX="tmp_svn_batch_$$" 32 echo "$FILES" | split -l "$BATCH_SIZE" - "$TMP_PREFIX" 33 34 # Process each batch 35 # Add and commit files in each batch to the repository 36 for BATCH_FILE in ${TMP_PREFIX}*; do 37 echo -e "\033[1;32mProcessing part $PART/$NUM_PARTS...\033[0m" 38 # Add all files in the batch at once 39 cat "$BATCH_FILE" | xargs svn add --force 40 # Commit all files in the batch at once 41 cat "$BATCH_FILE" | xargs svn ci -m "add tags/$VERSION - part $PART/$NUM_PARTS" 42 rm "$BATCH_FILE" 43 PART=$((PART + 1)) 44 done 40 echo "All commits for version $VERSION completed."
Note: See TracChangeset
for help on using the changeset viewer.