Skip to content

Instantly share code, notes, and snippets.

@mgirouard
Created February 1, 2012 05:38
Show Gist options
  • Save mgirouard/1715320 to your computer and use it in GitHub Desktop.
Save mgirouard/1715320 to your computer and use it in GitHub Desktop.
Index all vendor repositories in a directory
#!/bin/bash
function git_uri ()
{
echo $(git remote -v | grep "$1" | grep "fetch" | sed -E -e 's/^[a-z]+| |\(.+\)//g')
}
for VENDOR in `ls`; do
# Skip files
[[ -f $VENDOR ]] && continue
# Enter the directory (Git requires this for some reason)
pushd $VENDOR > /dev/null
# Determine repo type
[[ -d .git ]] && TYPE="Git" || TYPE="SVN"
if [[ $TYPE == 'Git' ]]; then
URL=$(git_uri 'origin')
UPSTREAM=$(git_uri 'upstream')
else
URL=$(svn info | grep "URL" | sed -E -e 's/URL: +//g')
fi
echo "$TYPE $VENDOR $URL $UPSTREAM"
popd > /dev/null
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment