-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgit-export-svn.sh
executable file
·71 lines (63 loc) · 1.93 KB
/
git-export-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
#!/bin/sh
#
# (c) 2010 David Soria Parra
# (c) 2010 Nils Adermann
# ----------------------------------------------------------------------------
# "THE BEER-WARE LICENSE" (Revision 42):
# <dsp@php.net> and <naderman@naderman.de wrote this file.
# As long as you retain this notice you
# can do whatever you want with this stuff. If we meet some day, and you think
# this stuff is worth it, you can buy me a beer in return.
# ----------------------------------------------------------------------------
# Make sure there are two arguments
if [ $# -lt 2 ]
then
echo "Usage: git-export-svn REMOTE BRANCH SVNAUTH"
echo " REMOTE The git remote to pull from"
echo " BRANCH The git branch to pull from"
echo " SVNAUTH The svn authentication to use"
echo " (--username <user> --password <pass>)"
echo "This script has to be run from within a checked out svn branch."
exit 1
fi
remote=$1
branch=$2
svnauth=$3
svn revert -R .
git pull $remote
lc=0
cont=0
if test -f "git-revision"
then
lc=`cat git-revision`
cont=1
else
echo "no git-revision found"
continue
fi
for hash in `git log --reverse --first-parent --pretty='format:%H' $lc..$branch`
do
echo "update to $hash"
git checkout -f $hash
if ! git log -n 1 --pretty=fuller $hash > COMMIT_MSG
then
echo "Canno get log" >&2
exit 127;
fi
cat COMMIT_MSG
for file in `git diff-tree -r --name-only --diff-filter=A HEAD~1..HEAD`
do
echo "add $file"
svn add --parents $file
done
for file in `git diff-tree -r --name-only --diff-filter=D HEAD~1..HEAD`
do
echo "del $file"
svn rm $file
done
echo $hash > git-revision
svn add git-revision
svn commit $svnauth -F COMMIT_MSG
svn up $svnauth
done
git checkout $branch