Simple Dockerfile to run the Ruby Nirvdrum/SVN2Git script under a Docker container!
-
Nirvdrum/SVN2Git works better then my own Rikj000/SVN-to-Git-convert tool,
which I will archive in favor of this container. -
Nirvdrum/SVN2Git requires a very old version of Git (
v1.8.3.1) to successfully convert branches + tags,
which is not shipped by Linux distributions anymore, so this container builds it from source.
See: https://github.com/nirvdrum/svn2git/blob/v2.4.0/lib/svn2git/migration.rb#L353 -
Nirvdrum/SVN2Git is not actively maintained anymore,
which leads to unresolved bugs in the official version, which this container seeks to patch out.Current patches:
- Download the latest
Dockerfilefrom theRuby-SVN2Git-Dockerreleases
wget "$(
curl -s -H "Accept: application/vnd.github.v3+json" \
'https://api.github.com/repos/Rikj000/Ruby-SVN2Git-Docker/releases/latest' \
| jq .assets[0].browser_download_url | sed -e 's/^"//' -e 's/"$//')";- Build svn2git container
docker build . -t svn2git:v2.4.0;- Check out the SVN repository at the latest revision
svn checkout \
"file:///path/to/svn/input/repo/@HEAD" \
"/path/to/svn/output/checkout/";- Query SVN checkout version history for 'authors-file.txt'
cd "/path/to/svn/output/checkout/";
svn log -q | \
awk -F '|' '/^r/ {gsub(/ /, "", $2); sub(" $", "", $2); print $2" = "$2" <"$2">"}' | \
sort -u > "/path/to/authors-file.txt";- Run svn2git container example
mkdir "/path/to/git/output/repo/";
docker run \
--volume "/path/to/git/output/repo:/var/svn2git" \
--volume "/path/to/svn/input/repo:/var/svn" \
--volume "/path/to/authors-file.txt:/var/authors-file.txt" \
svn2git:v2.4.0 \
"file:///var/svn" \
--trunk "trunk_dir" \
--branches "branches_dir" \
--tags "tags_dir" \
--authors "/var/authors-file.txt";Note --rootistrunk is broken, instead use --trunk "/" --nobranches --notags
See: nirvdrum/svn2git#127
Note --exclude is broken
- Push all branches + tags to Forgejo (or another Git forge like Github/Gitlab)
cd "/path/to/git/output/repo/";
git remote add origin http://localhost:3000/username/projectname;
git push origin '*:*';