public
Description: Simple shell script to import svn:externals into a local git-svn repository
Homepage:
Clone URL: git://github.com/andrep/git-svn-clone-externals.git
git-svn-clone-externals / git-svn-clone-externals
100755 50 lines (35 sloc) 1.165 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/bash
 
set -e
 
toplevel_directory="$(git rev-parse --show-cdup)"
current_directory="$(git rev-parse --show-prefix)"
 
git svn propget svn:externals . | while read -a words
do
  [ -z "${words[*]}" ] && continue
 
local_directory="${words[0]}"
  revision=""
  remote_url="${words[1]}"
 
  if [ -n "${words[2]}" ]; then
revision="${words[1]}"
    remote_url="${words[2]}"
  fi
 
echo "$local_directory -> $remote_url"
 
  mkdir -p .git_externals
  
  if [ -n "$revision" ]; then
      (cd .git_externals \
          && git svn clone "$revision" "$remote_url" "$local_directory")
  else
      (cd .git_externals \
          && git svn clone "$remote_url" "$local_directory")
  fi
 
ln -s .git_externals/"$local_directory" "$local_directory"
 
  git_excludes_path="$toplevel_directory".git/info/exclude
  if ! grep -q '^'"$current_directory".git_externals'$' "$git_excludes_path"
  then
echo "$current_directory".git_externals >> "$git_excludes_path"
  fi
 
if ! grep -q '^'"$current_directory""$local_directory"'$' "$git_excludes_path"
  then
echo "$current_directory""$local_directory" >> "$git_excludes_path"
  fi
 
done
 
# :vi:sw=2 sts=2 ft=bash