Coder Social home page Coder Social logo

svn2github-bash's Introduction

svn2github-bash

This script migrates a subversion repository to GitHub, with some logic for dealing with nested repositories.

Requirements

This script was developed using Ubuntu 18.04 with the following packages installed:

  • bc
  • git
  • git-lfs
  • git-svn
  • subversion

To install, run the following commands:

sudo apt-get update
sudo apt-get install git git-svn git-lfs subversion bc

Building the Docker container

docker build -t github/svn2github .

Features

  • Sizing of the remote repository
  • Detection of nested folders with trunk, tags and branches
  • Selectable subfolders for conversion to git submodules
  • Progress bar
  • Failed fetch retries
  • Large file detection, with automatic LFS initialization

Usage

chmod +x svn2github.sh
./svn2github.sh

Running in Docker

  1. Run the container
docker run -dit --name svn2github github/svn2github
  1. Enter a shell prompt in the container
docker exec -it svn2github bash
  1. Edit the settings.ini file
  2. Create your authors file
source settings.ini
svn log -q ${REPOSITORY} | awk -F '|' '/^r/ {sub("^ ", "", $2); sub(" $", "", $2); print $2" = "$2" <"$2"@example.com>"}' | sort -u >> ${AUTHORS_FILE}
   --OR--
source settings.ini
svn log --q ${REPOSITORY} | awk '/^r/{print $3" = "$3" <"$3"@example.com>"}'|sort -u|tee /tmp/authors.txt
  1. Edit the authors file to contain the correct user data
  2. Execute the script
./svn2github.sh

Running in Windows (Git-Bash)

  1. Download the release and extract it
  2. Ensure you have a Subversion client installed with the CLI utilities.
  3. Open the Git Bash terminal
  4. Add the Subversion binaries to your path
    • export PATH=${PATH}:/c/Program\ Files/TortoiseSVN/bin
  5. Edit the settings.ini file and add your specifics
  6. Add your git config properties
    • git config --global user.name "Kal El"
    • git config --global user.email "[email protected]"
  7. Execute the svn2github.sh script and follow the prompts
    • ./svn2github.sh

Using individual functions

_svn_sizer

$ source settings.ini
$ source _functions.sh
$ _svn_sizer
###################################
##                               ##
##  Discovering repository size  ##
##                               ##
###################################

Total Size: 545.575 MB
Number of Files: 17.276 K

Testing

This script was successfully tested with the following repositories:

URL Name Has Submodules Has Branches Has Tags
https://svn.eionet.europa.eu/repositories/NatureWatch NatureWatch Yes Only in submodules Yes
https://svn.code.sf.net/p/ultrastardx/svn ultrastardx No Yes Yes

Sample settings.ini

REPOSITORY=https://svn.eionet.europa.eu/repositories/NatureWatch
GITHUB_TOKEN=faf0bc75ea0740ef240g2cce40a488aa98229ef3
GITHUB_URL=https://ghe-test.github.local
GITHUB_ORG=GitHub-Demo
AUTHORS_FILE=/tmp/authors.txt
SVN_USERNAME=anonymous
SVN_PASSWORD=anonymous
ENABLE_SUBMODULES=true
MIGRATE_HISTORY=true

Caveats

  1. You may encounter issues with unsigned or self-signed certificates. In this case, disable http.sslVerify before running the script: git config --global http.sslVerify false

Remember to remove this when you're done!!

  1. You may encounter issues with cloning the history if your repository has corrupt revisions. In this case, it will be required to do a clean cutover. This script does not yet fully support a clean cutover, but it is in the works

  2. If you have a trunk folder and files in the root of the repository, the script will treat the root as trunk. This is because git-svn cannot treat 2 folders like master. If this is not the desired behavior then it is up to the administrator to consolidate these files either in trunk or in the root. If no consolidation is done, you will still have all of those files, and a trunk folder in your master branch after the migration

  3. Git-LFS is automatically initialized if large files are discovered, but this does not get around the max filesize limit of GitHub. You will still need to either increase that filesize temporarily for the migration, or else manually clean up the files. This is not handled by the script

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.