1 |
#!/bin/sh |
2 |
export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/pkg/bin:/usr/pkg/sbin:/usr/local/bin:/usr/local/sbin |
3 |
GIT=`mktemp -d` |
4 |
CVS=`mktemp -d` |
5 |
LOG=`mktemp` |
6 |
if [ "x$1" = "x" ]; then |
7 |
echo "Usage: $0 git cvs" |
8 |
exit 1 |
9 |
fi |
10 |
if [ "x$2" = "x" ]; then |
11 |
echo "Usage: $0 git cvs" |
12 |
exit 1 |
13 |
fi |
14 |
git clone $1 $GIT |
15 |
cd $GIT |
16 |
TAGS=`git tag` |
17 |
BRANCHES=`git branch -laq --format "%(refname:short)"` |
18 |
cvs co $2 $CVS |
19 |
cd $CVS |
20 |
cp -rf $GIT $CVS/trunk |
21 |
rm -rf $CVS/trunk/.git |
22 |
mkdir $CVS/branches $CVS/tags |
23 |
for i in $TAGS; do |
24 |
cd $GIT |
25 |
git checkout tags/$i |
26 |
if [ ! "$?" = "0" ]; then |
27 |
echo "Git tag $i was not successfully copied" >> $LOG |
28 |
continue |
29 |
fi |
30 |
cp -rf $GIT $CVS/tags/`echo $i | sed "s%/%-%g"` |
31 |
if [ "$?" = "0" ]; then |
32 |
echo "Git tag $i was successfully copied" >> $LOG |
33 |
else |
34 |
echo "Git tag $i was not successfully copied" >> $LOG |
35 |
continue |
36 |
fi |
37 |
rm -rf $CVS/tags/`echo $i | sed "s%/%-%g"`/.git |
38 |
done |
39 |
for i in $BRANCHES; do |
40 |
cd $GIT |
41 |
git checkout $i |
42 |
if [ ! "$?" = "0" ]; then |
43 |
echo "Git branch $i was not successfully copied" >> $LOG |
44 |
continue |
45 |
fi |
46 |
cp -rf $GIT $CVS/branches/`echo $i | sed "s%/%-%g"` |
47 |
if [ "$?" = "0" ]; then |
48 |
echo "Git branch $i was successfully copied" >> $LOG |
49 |
else |
50 |
echo "Git branch $i was not successfully copied" >> $LOG |
51 |
continue |
52 |
fi |
53 |
rm -rf $CVS/branches/`echo $i | sed "s%/%-%g"`/.git |
54 |
done |
55 |
cd $CVS |
56 |
cvs add trunk branches tags |
57 |
cat $LOG |
58 |
cvs ci -m "Migrated from Git repository: $1" |
59 |
rm -rf $CVS $GIT $LOG |