Skip to content

Instantly share code, notes, and snippets.

@gjoseph
Last active August 29, 2015 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gjoseph/a2bcf9f6bca6edcd8a45 to your computer and use it in GitHub Desktop.
Save gjoseph/a2bcf9f6bca6edcd8a45 to your computer and use it in GitHub Desktop.
#!/bin/bash
pattern=$1
if [ -z $pattern ]; then
echo "Please pass a pattern ! (e.g 'modules')"
exit -3
fi
output=`ssh git@git.magnolia-cms.com expand $pattern`
echo "$output" | grep '^only' > /dev/null
there_is_more=$?
if [ $there_is_more -eq 0 ]; then
echo "Too many repos matched by the $pattern pattern. Refine it to make sure the one you need gets cloned!"
echo ""
fi
filtered_list=`echo "$output" | grep -E '^ (@|#|&| )R' | cut -f3`
if [ -z "$filtered_list" ]; then
echo "No matching repo found. Please relax your pattern."
exit -4
fi
echo "Will attempt to clone the following repos:"
echo "$filtered_list" | sed 's/^/ /'
echo ""
echo "$filtered_list" | while read r; do
echo "> Cloning $r"
#git clone --bare git@git.magnolia-cms.com:$r $r.git
#git clone git@git.magnolia-cms.com:$r $r.git
git clone git@git.magnolia-cms.com:$r $r
echo ""
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment