2024-07-31 06:22:18 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
2024-08-03 09:22:15 +02:00
|
|
|
repos_file="./repos.txt"
|
2024-07-31 06:22:18 +02:00
|
|
|
|
2024-07-31 06:24:15 +02:00
|
|
|
# Check if the repos file exists
|
|
|
|
if [ ! -f "$repos_file" ]; then
|
2024-08-03 09:22:15 +02:00
|
|
|
echo "Error: $repos_file does not exist in the current directory."
|
2024-07-31 06:24:15 +02:00
|
|
|
exit 1
|
|
|
|
fi
|
2024-07-31 06:22:18 +02:00
|
|
|
|
2024-07-31 06:24:15 +02:00
|
|
|
# Read the repos file and process each directory
|
|
|
|
while IFS= read -r repo_path || [[ -n "$repo_path" ]]; do
|
|
|
|
# Trim whitespace
|
|
|
|
repo_path=$(echo "$repo_path" | xargs)
|
2024-07-31 06:22:18 +02:00
|
|
|
|
2024-07-31 06:24:15 +02:00
|
|
|
# Skip empty lines
|
|
|
|
[ -z "$repo_path" ] && continue
|
2024-07-31 06:22:18 +02:00
|
|
|
|
2024-07-31 06:24:15 +02:00
|
|
|
echo "Processing repository: $repo_path"
|
2024-07-31 06:22:18 +02:00
|
|
|
|
2024-07-31 06:24:15 +02:00
|
|
|
# Navigate to the project directory
|
|
|
|
if ! cd "$repo_path"; then
|
|
|
|
echo "Error: Unable to change to directory $repo_path. Skipping."
|
|
|
|
continue
|
|
|
|
fi
|
2024-07-31 06:22:18 +02:00
|
|
|
|
2024-07-31 06:24:15 +02:00
|
|
|
# Check if it's a git repository
|
|
|
|
if [ ! -d .git ]; then
|
|
|
|
echo "Warning: $repo_path is not a git repository. Skipping."
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Force pull the latest changes from the repository
|
|
|
|
echo "Force pulling latest changes..."
|
|
|
|
git pull --force
|
|
|
|
|
2024-08-03 09:22:15 +02:00
|
|
|
# Return to the original directory
|
|
|
|
cd - > /dev/null
|
|
|
|
|
2024-07-31 06:24:15 +02:00
|
|
|
echo "Update complete for $repo_path"
|
|
|
|
echo "----------------------------------------"
|
|
|
|
done < "$repos_file"
|
|
|
|
|
|
|
|
echo "All repositories processed."
|
2024-07-31 06:22:18 +02:00
|
|
|
|