Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Hi Andre #17

Merged
merged 2 commits into from

2 participants

@eipipuz

Your script was very useful but I have to tweaked it a little to understand it.

I changed the README to explicitly state that it won't work if SVN asks for a password as EVAL will swallow it.
I changed the clone-export to make it clear the case when it finds a revision field and when it doesn't.

Hope you find my changes useful additions to your useful script :)

eipipuz added some commits
@eipipuz eipipuz This should improve the code to handle when there's not revision spec…
…ified.
5c8be46
@eipipuz eipipuz add small note against the cryptic:
Password: 
Password: 
Password: 
RA layer request failed: OPTIONS of '<repo>': SSL handshake failed, client certificate was requested: SSL error: sslv3 alert handshake failure (<svn server>) at /usr/libexec/git-core/git-svn line 2079
fe79bbf
@andrep andrep merged commit ed99f65 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 6, 2012
  1. @eipipuz
  2. @eipipuz

    add small note against the cryptic:

    eipipuz authored
    Password: 
    Password: 
    Password: 
    RA layer request failed: OPTIONS of '<repo>': SSL handshake failed, client certificate was requested: SSL error: sslv3 alert handshake failure (<svn server>) at /usr/libexec/git-core/git-svn line 2079
This page is out of date. Refresh to see the latest.
Showing with 81 additions and 75 deletions.
  1. +2 −0  README.txt
  2. +79 −75 git-svn-clone-externals
View
2  README.txt
@@ -24,6 +24,8 @@ integration scripts that I've found. I absolutely do welcome those features,
but I figured I'd push this out since it works for me and is probably useful
for others.
+NB: This assumes you have passwordless svn.
+
Enjoy,
- Andre Pang <ozone@algorithm.com.au>
View
154 git-svn-clone-externals
@@ -8,78 +8,78 @@ toplevel_directory="$(git rev-parse --show-cdup)"
function call()
{
- cmd="$@"
- echo "$cmd"
- eval "$cmd"
- return "$?"
+ cmd="$@"
+ echo "$cmd"
+ eval "$cmd"
+ return "$?"
}
function do_clone()
{
- test -d .git_externals || return 1
- module=`echo $remote_url|sed 's,\(.*\)\(/trunk\|/branch.*\|/tag.*\),\1,'`
- branch=`echo $remote_url|sed 's,\(.*\)\(/trunk\|/branch.*\|/tag.*\),\2,'|sed 's,^/,,'`
- if [[ $branch = $remote_url ]]; then
- branch=""
- fi
- (
- cd .git_externals
- if [ -d "$local_directory" ]; then
- (
- cd "$local_directory"
- call git svn fetch --all
- )
- else
- tags="tags"
- brch="branches"
- branchpath=$(echo $branch|cut -f1 -d/)
- echo $tags|grep $branchpath >/dev/null 2>&1 && tags=$branchpath
- echo $brch|grep $branchpath >/dev/null 2>&1 && brch=$branchpath
-
- if [ "$module" = "$remote_url" ]; then
- # URL does not contains any trunk, branches or tags part, so we dont need
- # additional options for git-svn
- call git svn clone "$revision" "$module" "$local_directory"
- else
- call git svn clone "$revision" "$module" -T trunk -b $brch -t $tags "$local_directory"
- fi
-
- fi
- (
- branch="$(echo ${branch}|sed 's,/$,,')"
- if [ -n "$branch" ]; then
- cd "$local_directory"
- call git reset --hard $branch
- fi
- )
- )
+ test -d .git_externals || return 1
+ module=`echo $remote_url|sed 's,\(.*\)\(/trunk\|/branch.*\|/tag.*\),\1,'`
+ branch=`echo $remote_url|sed 's,\(.*\)\(/trunk\|/branch.*\|/tag.*\),\2,'|sed 's,^/,,'`
+ if [[ $branch = $remote_url ]]; then
+ branch=""
+ fi
+ (
+ cd .git_externals
+ if [ -d "$local_directory" ]; then
+ (
+ cd "$local_directory"
+ call git svn fetch --all
+ )
+ else
+ tags="tags"
+ brch="branches"
+ branchpath=$(echo $branch|cut -f1 -d/)
+ echo $tags|grep $branchpath >/dev/null 2>&1 && tags=$branchpath
+ echo $brch|grep $branchpath >/dev/null 2>&1 && brch=$branchpath
+
+ if [ "$module" = "$remote_url" ]; then
+ # URL does not contains any trunk, branches or tags part, so we dont need
+ # additional options for git-svn
+ call git svn clone "$revision" "$module" "$local_directory"
+ else
+ call git svn clone "$revision" "$module" -T trunk -b $brch -t $tags "$local_directory"
+ fi
+
+ fi
+ (
+ branch="$(echo ${branch}|sed 's,/$,,')"
+ if [ -n "$branch" ]; then
+ cd "$local_directory"
+ call git reset --hard $branch
+ fi
+ )
+ )
}
function do_link()
{
- dir="$1"
- base="$(dirname $dir)"
- (
- mkdir -p "$base"
- cd $base
- rel=$(git rev-parse --show-cdup)
- ln -sf ${rel}.git_externals/"$dir"
- )
+ dir="$1"
+ base="$(dirname $dir)"
+ (
+ mkdir -p "$base"
+ cd $base
+ rel=$(git rev-parse --show-cdup)
+ ln -sf ${rel}.git_externals/"$dir"
+ )
}
function do_excludes()
{
- dir="$1"
- git_excludes_path=.git/info/exclude
- if ! grep -q '^.git_externals$' "$git_excludes_path"
- then
- echo .git_externals >> "$git_excludes_path"
- fi
-
- if ! grep -q '^'"$dir"'$' "$git_excludes_path"
- then
- echo "$dir" >> "$git_excludes_path"
- fi
+ dir="$1"
+ git_excludes_path=.git/info/exclude
+ if ! grep -q '^.git_externals$' "$git_excludes_path"
+ then
+ echo .git_externals >> "$git_excludes_path"
+ fi
+
+ if ! grep -q '^'"$dir"'$' "$git_excludes_path"
+ then
+ echo "$dir" >> "$git_excludes_path"
+ fi
}
function is_excluded()
@@ -91,28 +91,33 @@ function is_excluded()
local result=1
fi
fi
- echo $result
+ echo $result
return
}
-git svn show-externals|grep -vE '#|^$'| \
- sed 's/\(-r\)[ ]*\([0-9]\{1,\}\)/\1\2/'|while read -a words
+git svn show-externals | grep -vE '#|^$' | \
+ sed 's/\(-r\)[ ]*\([0-9]\{1,\}\)/\1\2/' | \
+ while read svn_externals
do
- [ -z "${words[*]}" ] && continue
- local_directory="$(echo ${words[0]}|sed 's,^/,,')"
- revision=""
- remote_url="${words[1]}"
+ number_fields="$(echo ${svn_externals}|awk '{print NF}')"
+ case $number_fields in
+ 2)
+ local_directory="$(echo ${svn_externals} | awk '{print $1}' | sed 's,^/,,')"
+ revision=""
+ remote_url="$(echo ${svn_externals} | awk '{print $2}')"
+ ;;
+ 3)
+ local_directory="$(echo ${svn_externals} | awk '{print $1}' | sed 's,^/,,')"
+ revision=""$(echo ${svn_externals} | awk '{print $2}')
+ remote_url="$(echo ${svn_externals} | awk '{print $3}')"
+ ;;
+ *) continue ;;
+ esac
check_excluded=$(is_excluded $local_directory)
-
if [ $check_excluded -eq 0 ] ; then
- if [ -n "${words[2]}" ]; then
- revision="${words[1]}"
- remote_url="${words[2]}"
- fi
-
if [ -n "$USE_SSH" ]; then
echo "Rewriting url to use SVN+SSH."
shopt -s extglob
@@ -133,5 +138,4 @@ do
do_excludes "$local_directory"
fi
-done
-
+done
Something went wrong with that request. Please try again.