Permalink
Browse files

added the possibility of having a file for excluding externals

  • Loading branch information...
1 parent fcdfc31 commit 018f6493523a7b3d2db759f341669e7c1fd0ecc0 @trodrigues trodrigues committed Mar 18, 2011
Showing with 37 additions and 17 deletions.
  1. +3 −0 README.txt
  2. +34 −17 git-svn-clone-externals
View
@@ -74,6 +74,9 @@ Options
* External repository's url can be rewritten, to use SVN+SSH instead of
plain HTTP or HTTPS. To do so, do `export USE_SSH=yes` in your environment.
This can be useful if you use ssh authentication, but other developers don't.
+* If you don't want to pull all external repositories, you can create a
+ .git_externals_exclude file which contains the local paths to be excluded,
+ one per line, the same way they show up on the first field of git svn show-externals
- Alexander Artemenko <svetlyak.40wt@gmail.com>
View
@@ -82,6 +82,19 @@ function do_excludes()
fi
}
+function is_excluded()
+{
+ local result=0
+ if [ -f .git_externals_exclude ] ; then
+ matches=`grep -v "^#" .git_externals_exclude|grep "^/$1$"|wc -l`
+ if [ $matches -gt 0 ] ; then
+ local result=1
+ fi
+ fi
+ echo $result
+ return
+}
+
git svn show-externals|grep -vE '#|^$'|while read -a words
do
@@ -91,29 +104,33 @@ do
revision=""
remote_url="${words[1]}"
- if [ -n "${words[2]}" ]; then
- revision="${words[1]}"
- remote_url="${words[2]}"
- fi
+ check_excluded=$(is_excluded $local_directory)
- if [ -n "$USE_SSH" ]; then
- echo "Rewriting url to use SVN+SSH."
- shopt -s extglob
- remote_url="${remote_url/+(http|https)/svn+ssh}"
- fi
+ if [ $check_excluded -eq 0 ] ; then
+ if [ -n "${words[2]}" ]; then
+ revision="${words[1]}"
+ remote_url="${words[2]}"
+ fi
- [ -z "${remote_url}" ] && continue
+ if [ -n "$USE_SSH" ]; then
+ echo "Rewriting url to use SVN+SSH."
+ shopt -s extglob
+ remote_url="${remote_url/+(http|https)/svn+ssh}"
+ fi
- export local_directory revision remote_url
+ [ -z "${remote_url}" ] && continue
- echo "$local_directory -> $remote_url"
+ export local_directory revision remote_url
- dir=`dirname $local_directory`
- [ -d ".git_externals/$dir" ] || mkdir -p ".git_externals/$dir"
+ echo "$local_directory -> $remote_url"
- do_clone "$revision" "$remote_url" "$local_directory" || exit
- do_link "$local_directory"
- do_excludes "$local_directory"
+ dir=`dirname $local_directory`
+ [ -d ".git_externals/$dir" ] || mkdir -p ".git_externals/$dir"
+
+ do_clone "$revision" "$remote_url" "$local_directory" || exit
+ do_link "$local_directory"
+ do_excludes "$local_directory"
+ fi
done

0 comments on commit 018f649

Please sign in to comment.