Auto-update: Tue Jul 30 21:24:15 PDT 2024

This commit is contained in:
sanj 2024-07-30 21:24:15 -07:00
parent d0d8181f30
commit f901f0c608

49
pull
View file

@ -1,25 +1,42 @@
#!/bin/bash #!/bin/bash
output_file=~/workshop/repos.txt repos_file=~/workshop/repos.txt
# Ensure the output directory exists # Check if the repos file exists
mkdir -p "$(dirname "$output_file")" if [ ! -f "$repos_file" ]; then
echo "Error: $repos_file does not exist."
exit 1
fi
# Clear the existing file # Read the repos file and process each directory
> "$output_file" while IFS= read -r repo_path || [[ -n "$repo_path" ]]; do
# Trim whitespace
repo_path=$(echo "$repo_path" | xargs)
# Find all .git directories, excluding hidden directories and suppressing permission denied errors # Skip empty lines
find ~/ -type d -name ".git" -not -path "*/.*/*" 2>/dev/null | while read -r gitdir; do [ -z "$repo_path" ] && continue
# Get the parent directory of the .git folder
repo_path=$(dirname "$gitdir")
echo "$repo_path" >> "$output_file"
done
echo "Git repositories have been written to $output_file" echo "Processing repository: $repo_path"
# Remove duplicate entries # Navigate to the project directory
sort -u "$output_file" -o "$output_file" if ! cd "$repo_path"; then
echo "Error: Unable to change to directory $repo_path. Skipping."
continue
fi
echo "Duplicate entries removed. Final list:" # Check if it's a git repository
cat "$output_file" 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
echo "Update complete for $repo_path"
echo "----------------------------------------"
done < "$repos_file"
echo "All repositories processed."