-
Notifications
You must be signed in to change notification settings - Fork 0
/
mirror_svn.sh
executable file
·76 lines (60 loc) · 1.4 KB
/
mirror_svn.sh
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/bin/bash
set -e
if [ ! $# -eq 1 ];
then
echo "Usage:"
echo "$0 "
exit 1
fi
CONFIG_FILE="$1"
source "${CONFIG_FILE}" || exit 1
SVN_CLONE="${PROJECT_ROOT}/svn-clone"
GIT_BARE="${PROJECT_ROOT}/git-bare-tmp"
if [ ! -d "${PROJECT_ROOT}" ];
then
mkdir -p "${PROJECT_ROOT}"
fi
cd "${PROJECT_ROOT}"
if [ ! -d "${SVN_CLONE}" ];
then
echo "git svn clone ${SVN_REPO} ${SVN_LAYOUT} ${SVN_CLONE}"
git svn clone \
"${SVN_REPO}" \
${SVN_LAYOUT} \
"${SVN_CLONE}"
cd "${SVN_CLONE}"
else
cd "${SVN_CLONE}"
git remote rm bare || echo "failed to delete remote:bare, proceeding anyway"
git svn rebase \
--fetch-all
# -A "${AUTHORS_FILE}"
fi
git remote add bare "${GIT_BARE}"
git config remote.bare.push 'refs/remotes/origin/*:refs/heads/*'
git svn show-ignore -i origin/trunk > .gitignore
if [ -d "${GIT_BARE}" ];
then
rm -rf "${GIT_BARE}"
fi
mkdir -p "${GIT_BARE}"
cd "${GIT_BARE}"
git init --bare .
git symbolic-ref HEAD refs/heads/trunk
cd "${SVN_CLONE}"
git push bare
cd "${GIT_BARE}"
git branch -m trunk master
git for-each-ref --format='%(refname)' refs/heads/tags | \
cut -d / -f 4 | \
while read ref;
do
git tag "$ref" "refs/heads/tags/$ref"
git branch -D "tags/$ref"
done
git remote add origin "${GIT_REPO}"
git config branch.master.remote origin
git config branch.master.merge refs/heads/master
git push --tags origin master
git push --all
rm -rf "${GIT_BARE}"