Skip to content

Commit 4c6885b

Browse files
committed
Add a simple script to maintain Git mirrors of CVS repositories
This, too, is meant for Jenkins jobs. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
1 parent 424d3d8 commit 4c6885b

1 file changed

Lines changed: 79 additions & 0 deletions

File tree

git-cvs-synchronizer.sh

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
#!/bin/sh
2+
3+
# This script uses rsync and cvs2git for Sourceforge projects, and cvsimport
4+
# for all other CVS projects, to keep a Git mirror of CVS repositories
5+
#
6+
# Usage: git-cvs-synchronizer.sh <CVS-spec> <Git-Push-URL>...
7+
#
8+
# where <CVS-spec> is the the CVS root followed by a colon and the name of the
9+
# CVS module.
10+
#
11+
# Example: git-cvs-synchronizer.sh \
12+
# :pserver:anonymous@tcljava.cvs.sourceforge.net:/cvsroot/tcljava:tcljava \
13+
# fiji.sc:/srv/git/tcljava/.git
14+
15+
if test $# -lt 2
16+
then
17+
echo "Usage: $0 <CVSROOT>:<MODULE> <GIT-PUSH-URL>..." >&2
18+
exit 1
19+
fi
20+
21+
set -e
22+
23+
CVSROOT="${1%:*}"
24+
CVSMODULE="${1##*:}"
25+
shift
26+
27+
RSYNC_URL="$(echo "$CVSROOT" |
28+
sed -n 's/^:pserver:anonymous@\([^:]*\.cvs\.\(sourceforge\|sf\)\.net\):\/\(cvsroot\/.*\)/\1::\3/p')"
29+
30+
cvs2git () {
31+
test -d "$CVS2SVN" || {
32+
CVS2SVN=../../cvs2svn
33+
test -d "$CVS2SVN" ||
34+
git clone git://fiji.sc/cvs2svn "$CVS2SVN"
35+
}
36+
"$CVS2SVN"/cvs2git --blobfile=cvs.blobs --dumpfile=cvs.dump \
37+
--username=git-synchronizer cvs-mirror/
38+
cat cvs.blobs cvs.dump |
39+
git fast-import
40+
}
41+
42+
if test -n "$RSYNC_URL"
43+
then
44+
test -d .git || {
45+
git init
46+
mkdir -p .git/info
47+
echo /cvs-mirror/ >> .git/info/exclude
48+
}
49+
rsync -va "$RSYNC_URL/$CVSMODULE" cvs-mirror
50+
rsync -va "$RSYNC_URL/CVSROOT" cvs-mirror
51+
cvs2git
52+
else
53+
# TODO: try cvsclone (git://repo.or.cz/cvsclone.git)
54+
cvs -d "$CVSROOT" co "$CVSMODULE"
55+
cd "$CVSMODULE"
56+
case "$CVSROOT" in
57+
*cvs.dev.java.net*)
58+
EXTRA_CVSPS_OPTS="-p --no-rlog,--no-cvs-direct"
59+
;;
60+
*cvs.scms.waikato.ac.nz*)
61+
(cvs rlog $(cat CVS/Repository) |
62+
sed "/^The changelog prior to shifting was:$/,/^=\{77\}$/d" \
63+
> rlog-patched.out) 2>&1 |
64+
grep -ve "^rlog" -e "^connect" -e "^cvs r\?log" -e "^creating"
65+
EXTRA_CVSPS_OPTS="-p --test-log,rlog-patched.out"
66+
;;
67+
*)
68+
EXTRA_CVSPS_OPTS=
69+
;;
70+
esac
71+
git cvsimport -i -k $EXTRA_CVSPS_OPTS
72+
fi
73+
74+
refs="$(git for-each-ref --shell --format '%(refname)')"
75+
76+
for remote
77+
do
78+
eval git push \"$remote\" $refs
79+
done

0 commit comments

Comments
 (0)