mirror of https://github.com/CGAL/cgal
153 lines
3.7 KiB
Bash
Executable File
153 lines
3.7 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
### Usage
|
|
|
|
usage()
|
|
{
|
|
echo "Usage: `basename $0` [-u userName] [-e UserEmail] [-l userLogin] [-m svnLocation] [-r fromRevision] [-s] [-g gitname=cgal.git] [-v] [-h]" >&2
|
|
echo >&2
|
|
echo " -r gives revision to start from. Other options than a number: LAST, BASE" >&2
|
|
echo " -s skip fetch" >&2
|
|
echo " -v the version" >&2
|
|
echo " -h this info screen" >&2
|
|
echo >&2
|
|
}
|
|
|
|
### Config
|
|
|
|
userName="Eric Berberich"
|
|
userEmail=eric@mpi-inf.mpg.de
|
|
userLogin=eric
|
|
svnGforge=svn+ssh://$userLogin@scm.gforge.inria.fr/svn/cgal
|
|
fromSvn=file://$HOME/CGAL/gforge/cgal-m
|
|
#fromSvn=$svnGforge
|
|
fromRev=63050
|
|
gitName=cgal.git
|
|
skipFetch=0
|
|
|
|
# parse command line arguments
|
|
while getopts u:e:l:r:m:g:sh OPT; do
|
|
case "$OPT" in
|
|
u) userName=$OPTARG
|
|
;;
|
|
|
|
e) userEmail=$OPTARG
|
|
;;
|
|
|
|
l) userLogin=$OPTARG
|
|
;;
|
|
|
|
m) fromSvn=$OPTARG
|
|
;;
|
|
|
|
r) fromRev=$OPTARG
|
|
;;
|
|
|
|
s) skipFetch=1
|
|
;;
|
|
|
|
r) gitName=$OPTARG
|
|
;;
|
|
|
|
h) usage
|
|
exit 0
|
|
;;
|
|
|
|
v) echo "`basename $0` version 0.1"
|
|
exit 0
|
|
;;
|
|
|
|
\?) # getopts issues an error message
|
|
usage
|
|
exit 1
|
|
;;
|
|
esac
|
|
done
|
|
|
|
#shift `expr $OPTIND - 1`
|
|
|
|
### Create repo
|
|
|
|
echo "Create new directory $gitname"
|
|
rm -fr $gitName
|
|
mkdir $gitName
|
|
cd $gitName
|
|
echo
|
|
|
|
# rewrite root
|
|
rewriteRoot=--rewrite-root=$svnGforge
|
|
rewriteRoot=
|
|
|
|
# options to speedup
|
|
|
|
# TODO internal-releases only >= 3.7
|
|
internalReleasesTags="--tags tags/internal-releases"
|
|
internalReleasesTags=
|
|
|
|
debianTags="--tags tags/debian"
|
|
debianTags=
|
|
|
|
echo "Init repository: $CMD"
|
|
git svn init $fromSvn $rewriteRoot --prefix=svn/ --trunk trunk
|
|
git svn init $fromSvn $rewriteRoot --prefix=svn/branches/next/ --trunk branches/next
|
|
git svn init $fromSvn $rewriteRoot --prefix=svn/branches/features/ --branches branches/features
|
|
git svn init $fromSvn $rewriteRoot --prefix=svn/branches/releases/ --branches branches/releases
|
|
git svn init $fromSvn $rewriteRoot --prefix=svn/tags/releases/ --tags tags/releases
|
|
if [ "$internalReleasesTags" != "" ]; then
|
|
git svn init $fromSvn $rewriteRoot --prefix=svn/tags/internal-releases/ $internalReleasesTags
|
|
fi
|
|
if [ "$debianTags" != "" ]; then
|
|
git svn init $fromSvn $rewriteRoot --prefix=svn/tags/debian/ $debianTags
|
|
fi
|
|
# rename some refs
|
|
sed -e 's|trunk:|stable:|g' -e 's|next/trunk|next|g' -i "" .git/config
|
|
echo
|
|
|
|
# add author
|
|
CMD="git config user.name \"$userName\"; git config user.email \"$userEmail\""
|
|
echo "Add author to $gitName/.git/config: $CMD"
|
|
echo "PWD"
|
|
pwd
|
|
#$CMD
|
|
git config user.name "$userName"
|
|
git config user.email "$userEmail"
|
|
echo
|
|
|
|
echo "Using config $gitName/.git/config:"
|
|
cat .git/config
|
|
|
|
### Fetch
|
|
|
|
if [ $skipFetch = 0 ]; then
|
|
|
|
### Authors file
|
|
echo "Get authors file with svn"
|
|
svn cat $fromSvn/branches/next/Maintenance/git/authors-file.txt > /tmp/cgal-authors-file.txt
|
|
echo
|
|
|
|
# fetch from svn server
|
|
echo "Fetch from SVN repository: git svn fetch -r$fromRev:HEAD "
|
|
if [ "$fromRev" = "LAST" ]; then
|
|
# last revision on next
|
|
fromRev=$(svn info $fromSvn/branches/next | grep "Last Changed Rev: " | tr -d 'Last Changed Rev: ')
|
|
echo "Last Revision: $fromRev"
|
|
fi
|
|
git svn fetch --authors-file=/tmp/cgal-authors-file.txt -r$fromRev:HEAD
|
|
# TODO fetch each branch from its creation-revision only
|
|
echo
|
|
|
|
rm -f /tmp/cgal-authors-files.txt
|
|
|
|
### Branch names
|
|
|
|
# rename master next
|
|
echo "Rename main branch to local/next"
|
|
git branch -m master local/next
|
|
|
|
fi
|
|
|
|
|
|
# What about?
|
|
## git config svn-remote.svn.url $svncgal (or $svncgal/trunk if you are doing trunk only)
|
|
### http://translate.org.za/blogs/wynand/en/content/changing-your-svn-repository-address-git-svn-setup
|
|
## unhandled.log (which lists all svn properties, such as svn:eol, that has not been converted). |