Skip to content

Instantly share code, notes, and snippets.

@bbinet
Created November 28, 2011 15:30
Show Gist options
  • Save bbinet/1400782 to your computer and use it in GitHub Desktop.
Save bbinet/1400782 to your computer and use it in GitHub Desktop.
bash function to checkout svn:externals when using git-svn
function git-co-externals() {
(
cd $(git rev-parse --show-toplevel) && git svn show-externals | grep "^/" |
while read a b c
do
# remove first character which is a '/'
local=${a:1}
if [ -z $c ]
then
url=$b
rev=""
else
url=$c
rev=$b
fi
mkdir -p $local
(
echo "-------------------------------------"
echo "cd $local"
cd $local && if [ -d .svn ]
then
echo "svn up $rev"
svn up $rev
elif [ -d .git ]
then
if [ -z $rev ]
then
echo "git svn rebase && git-co-externals"
git svn rebase && git-co-externals
else
echo "/!\ Can't issue 'git svn rebase' on a specific revision"
echo "You should not use a local git repository in that case"
fi
else
echo "svn co $rev $url ."
svn co $rev $url .
fi
)
done
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment