blob: 1f75bd2d0e3c85b62bef0bc474ebab6f836a92bc (
plain)
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
# Reference: written following http://john.albin.net/git/convert-subversion-to-git
SOFTWARE=$1
if [ -z $SOFTWARE ]; then
echo "Missing software to convert..."
exit 1
fi
skiprevisions=
skiprevisionsx="$2"
if [ -n "$skiprevisionsx" ]; then
for rev in $skiprevisionsx; do
rev=$(echo $rev | sed 's/r//g')
rev=$(( $rev + 0 ))
if [ $rev -gt 0 ]; then
skiprevisions="$skiprevisions $rev"
fi
done
fi
# STEP 2: Import in git
git svn init http://svn.mandriva.com/svn/soft/$SOFTWARE --no-metadata --stdlayout temp
cd temp
revision=0
if [ -n "$skiprevisions" ]; then
for rev in $skiprevisions; do
git svn fetch -A ../authors-transform.txt -r $(( $revision + 1 )):$(( $rev - 1 ))
revision=$rev
done
fi
git svn fetch -A ../authors-transform.txt -r $(( $revision + 1 )):HEAD
git reset --hard trunk
cd ..
# STEP 3: Convert svn:ignore properties to .git ignore
cd temp
git svn show-ignore > .gitignore
git add .gitignore
git commit -m 'Convert svn:ignore properties to .gitignore.'
cd ..
# STEP 4: Create a bare repository
git init --bare new-bare.git
cd new-bare.git
git symbolic-ref HEAD refs/heads/trunk
cd ..
cd temp
git remote add bare ../new-bare.git
git config remote.bare.push 'refs/remotes/*:refs/heads/*'
git push bare
cd ..
# STEP 5: Rename trunk to master
cd new-bare.git
git branch -m trunk master
cd ..
# STEP 6: Cleanup branches and tags
cd new-bare.git
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
cd ..
mv new-bare.git $SOFTWARE.git
# CLEANUP
mv temp $SOFTWARE-origin
exit 0
|