-
Notifications
You must be signed in to change notification settings - Fork 164
/
plone-collective-svn2git.sh
executable file
·77 lines (60 loc) · 1.34 KB
/
plone-collective-svn2git.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
77
#!/bin/bash
###
#
# Script to migrate a repository from the subversion collective to a
# git repository.
#
# Based on: https://github.com/collective/collective.github.com/blob/master/old-svn.rst#make-a-proper-git-svn-fork
#
###
#
# Requires:
# - svn2git [github.com/nirvdrum/svn2git]
# - git-svn
#
###
#
# TODO:
#
###
set -e
SVN2GIT=${SVN2GIT:-svn2git}
[ -x $SVN2GIT ] ||
{
echo "The given svn2git ($SVN2GIT) does not exist or is not executable."
exit 1
}
BASEDIR="${PWD}"
ADDON=$1
REPO_URL=http://svn.plone.org/svn/collective/${ADDON}
# Create work directory
mkdir -vp "${ADDON}"
pushd "${ADDON}"
[ -f log.svn.txt ] ||
svn log -q ${REPO_URL} \
>log.svn.txt
[ -f authors-transform.txt ] ||
{ cat log.svn.txt \
| awk -F '|' '/^r/ {sub("^ ", "", $2); sub(" $", "", $2); print $2" = "$2" <"$2">"}' \
| sort -u \
>authors-transform.txt
$EDITOR authors-transform.txt
}
REV0=$(tail -n2 log.svn.txt | head -n1 | awk '{print $1}' | sed "s/r//")
[ -z "${REV0}" ] && {
echo Could not calculate the starting revision.
exit 1
}
REV1=$(head -n2 log.svn.txt | tail -n1 | awk '{print $1}' | sed "s/r//")
[ -z "${REV1}" ] && {
echo Could not calculate the ending revision.
exit 1
}
mkdir -p master
cd master
${SVN2GIT} \
--authors ../authors-transform.txt \
--revision ${REV0}:${REV1} \
-v \
${REPO_URL}
popd