Last active
April 19, 2024 06:57
-
-
Save sounddrill31/a72eef2c3a495c16433ce8f653859a09 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [ "$#" -ne 2 ]; then | |
echo "Usage: $0 <repository_url> <branch_name>" | |
exit 1 | |
fi | |
repo_url="$1" | |
branch_name="$2" | |
# Clone the repository | |
rm -rf repo || true | |
git clone "$repo_url" -b "$branch_name" repo | |
# Get XML paths from.repo/manifests | |
paths_1=$(find .repo/manifests -type f -name "*.xml" -exec grep -oP '(?<=<project path=")[^"]+' {} \;) | |
# Get XML paths from repo | |
paths_2=$(find repo -type f -name "*.xml" -exec grep -oP '(?<=<project path=")[^"]+' {} \;) | |
# Remove directories that are not present in the manifest | |
for path in $paths_1; do | |
if ! grep -q "$path" <<< "$paths_2"; then | |
echo "Removing $path" | |
rm -rf "$path" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment