]> Pileus Git - ~andy/fetchmail/blob - vcs-tools/fetchmail-svn2git.sh
Attempt merging from 6.3.24.
[~andy/fetchmail] / vcs-tools / fetchmail-svn2git.sh
1 #!/bin/sh
2
3 # fetchmail-svn2git.sh - (C) 2009, 2010 by Matthias Andree, GNU GPL v3.
4
5 set -eu
6
7 #######################################################################
8 # Adjust the next three settings below:
9
10 # safe can be obtained from <git://repo.or.cz/svn-all-fast-export.git>
11 # and must be built before we can use it:
12 safe="$HOME/VCS-other/svn-all-fast-export/svn-all-fast-export"
13
14 # svn is the path to a verbatim copy of the server-side SVN repository
15 # obtained with rsync or with svnadmin dump and load:
16 svn="$HOME/VCS-mine/fetchmail.svnrepo.backup"
17
18 # git specifies where you want the converted repository to end up.
19 git="$HOME/fetchmail.git"
20
21 #
22 #######################################################################
23
24 # There should be no need to change anything below:
25
26 #######################################################################
27
28 # obtain current directory
29 dir="$(dirname $0)"
30
31 # obtain absolute directory
32 dir="$( ( cd "$dir" && pwd ) )"
33
34 # Pluck these from the same directory as this script
35 auth="$dir/fetchmail.authors"
36 rule="$dir/fetchmail.rules"
37
38 # create git repository
39 mkdir "$git"
40 cd "$git"
41 git init
42
43 # run svn-all-fast-export, which already imports stuff into git
44 "$safe" --identity-map="$auth" "$rule" "$svn"
45
46 # turn tags/ branches into tags
47 git branch -a \
48 | grep _tag_ \
49 | while read a ; do
50         if git show-ref -q "$a" ; then
51                 (
52                 eval $(git log -1 --format="tformat:GIT_AUTHOR_NAME=\"%an\"%nGIT_AUTHOR_EMAIL=\"%ae\"%nGIT_AUTHOR_DATE=\"%ai\"%nGIT_COMMITTER_NAME=\"%cn\"%nGIT_COMMITTER_EMAIL=\"%ce\"%nGIT_COMMITTER_DATE=\"%ci\"" "$a")
53                 MSG=$(git log -1 --pretty="tformat:%s%n%n%b" "$a")
54                 export GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL GIT_AUTHOR_DATE
55                 export GIT_COMMITTER_NAME GIT_COMMITTER_EMAIL GIT_COMMITTER_DATE
56                 if test "$GIT_AUTHOR_NAME" = nobody ; then
57                         # cvs2svn tag => lightweight
58                         git tag "${a##_tag_}" "$a"
59                 else
60                         # keep message
61                         git tag -a -m "$MSG" "${a##_tag_}" "$a"
62                 fi
63                 git branch -D "$a"
64                 )
65         fi
66 done
67
68 # clean up
69 git gc --aggressive