mirror of https://github.com/CGAL/cgal
70 lines
2.0 KiB
Bash
Executable File
70 lines
2.0 KiB
Bash
Executable File
#!/bin/bash
|
|
REPO=/Users/eric/CGAL/GIT/test/cgal.git.fetch
|
|
REMOTE=/Users/eric/CGAL/GIT/test/cgal.git
|
|
SVN=https://svn.mpi-sb.mpg.de/AG1/eric/likeCGAL/
|
|
|
|
cd $REPO
|
|
|
|
echo "#Fetch from git on gForge"
|
|
|
|
|
|
### TODO Authors file
|
|
#echo "Get authors file with svn"
|
|
#svn cat $fromSvn/branches/next/Maintenance/git/authors-file.txt > /tmp/cgal-authors-file.txt
|
|
#echo
|
|
|
|
git svn fetch
|
|
|
|
rsync -avrP $REPO/.git/svn/ $REMOTE/svn/
|
|
|
|
#rm -f /tmp/cgal-authors-files.txt
|
|
|
|
echo "#Make the git stable branch always track the svn trunk"
|
|
git update-ref refs/heads/master refs/remotes/svn/trunk
|
|
git update-ref refs/heads/next refs/remotes/svn/next
|
|
|
|
echo "#Copy all other remote branches (only svn branches, excluding trunk and tags) to normal git branches"
|
|
git for-each-ref refs/remotes/svn/ | cut -d / -f 4- | grep -v -x trunk | grep -v tags | while read ref
|
|
do
|
|
git update-ref "refs/heads/$ref" "refs/remotes/svn/$ref"
|
|
done
|
|
|
|
echo "#Make a lightweight tag for any unseen svn tags, then delete the tags/tag branches"
|
|
git for-each-ref refs/remotes/svn/tags | cut -d / -f 5- | while read ref
|
|
do
|
|
git show-ref --quiet --verify "refs/tags/$ref" && continue
|
|
git tag "$ref" "refs/remotes/svn/tags/$ref"
|
|
git update-ref -d "refs/remotes/svn/tags/$ref" "refs/remotes/svn/tags/$ref"
|
|
done
|
|
|
|
echo "#Prune branches or tags that have been removed in svn"
|
|
git for-each-ref refs/heads | cut -d / -f 3- | grep -v -x master | grep -v -x next | while read ref
|
|
do
|
|
git show-ref --quiet --verify -- "refs/remotes/svn/$ref" || git update-ref -d "refs/heads/$ref" "refs/heads/$ref"
|
|
done
|
|
|
|
git for-each-ref refs/heads | cut -d / -f 3- | grep -v -x master | grep -v -x next | while read ref
|
|
do
|
|
svn ls "$SVN/branches/$ref" --depth empty
|
|
error=$?
|
|
if [ $error -ne 0 ]; then
|
|
git update-ref -d "refs/heads/$ref" "refs/heads/$ref"
|
|
git update-ref -d "refs/remotes/svn/$ref" "refs/remotes/svn/$ref"
|
|
fi
|
|
done
|
|
|
|
# TODO to the same for tags
|
|
|
|
echo "#Compact repository"
|
|
git gc --auto --prune=now
|
|
|
|
echo "#Push to $REMOTE"
|
|
git push $REMOTE --mirror
|
|
|
|
echo "#Set HEAD"
|
|
cd $REMOTE
|
|
git symbolic-ref HEAD refs/heads/next
|
|
|
|
exit
|
|
|