Giter VIP home page Giter VIP logo

svn2github's Introduction

svn2github

Mirror your SVN repositories to GitHub

Motivation

This is a standalone script created as a response to a few people asking for an alternative to using svn2github.com that I recently closed.

Requirements

This is a Python3 script (tested with Python 3.5). It shells out to the following commands:

  • svn
  • git
  • git svn (usually packaged separately from git!)
  • tar

Warning

Don't use the script on untrusted repositories. The script issues commands using input from the GitHub repository and possibly this can be exploited to run arbitrary commands on your server.

Usage

There are a few ways to use the script.

The first use case is mirroring an SVN repository to a completely fresh GitHub:

  1. Create a new repository using https://github.com/new
  2. Make sure you can clone that repository using SSH (git clone [email protected]:...), you need your SSH keys set up for this
  3. Invoke the script with the import subcommand: ./svn2github.py import github_user/repo http://svn-url/trunk
  4. To later synchronize the repo use update: ./svn2github.py update github_user/repo

The second use case is mirroring a repository that used to be kept in sync by svn2github.com:

  1. Fork repo from https://github.com/svn2github/repo to your new user and repo name
  2. Make sure you can clone that repository using SSH (git clone [email protected]:...), you need your SSH keys set up for this
  3. Bring the repo up to date with the update command: python3 svn2github.py github_user/repo update

All those commands (both import and update) will re-download the whole Git and SVN history every time, unless you specify a cache directory using the --cache-dir option. Use an empty directory and keep the contents between the runs to significantly speed up the updates!

Help page

usage: svn2github.py [-h] [--cache-dir CACHE_DIR] {import,update} ...

Mirror SVN repositories to GitHub

positional arguments:
  {import,update}
    import              Import SVN repository to the GitHub repo
    update              Update the GitHub repository from SVN

optional arguments:
  -h, --help            show this help message and exit
  --cache-dir CACHE_DIR
                        Directory to keep the cached data to avoid re-
                        downloading all SVN and Git history each time. This is
                        optional, but highly recommended

====

usage: svn2github.py import [-h] GITHUB_REPO SVN_URL

positional arguments:
  GITHUB_REPO  GitHub repo in format: user/name
  SVN_URL      SVN repository to import

optional arguments:
  -h, --help   show this help message and exit

====

usage: svn2github.py update [-h] GITHUB_REPO

positional arguments:
  GITHUB_REPO  GitHub repo in format: user/name

optional arguments:
  -h, --help   show this help message and exit

svn2github's People

Contributors

0cool-f avatar milahu avatar

Watchers

 avatar

svn2github's Issues

todo

# TODO first clone should go to cache, not /tmp
# TODO why binary strings?
# TODO why need ssh for github?
# TODO use github api, to add the last update time to the repo "about" text

error: RA layer request failed

svn2github import milahu/qmmp http://svn.code.sf.net/p/qmmp-dev/code
...
Fetching from SVN, revision 3740/10403RA layer request failed: REPORT request on '/p/qmmp-dev/code/!svn/me' failed at /nix/store/jmihw7x9jb4wjnk8xq5csh7xrpqycwm3-git-2.33.1/lib/perl5/site_perl/5.34.0/Git/SVN/Ra.pm line 312.

https://stackoverflow.com/questions/8451480/ra-layer-request-failed-report-request-failed-during-git-svn

suggests to skip broken revisions (in my case, revision 3740)

git svn clone -r 1:11 --stdlayout https://wtorrent-project.googlecode.com/svn/ wtorrent-git
# skip revisions 12 13 14
cd wtorrent-git
git svn fetch -r 15:HEAD

or

tidy up the git repository and then continue fetching from svn:

git gc
git svn fetch

related

1. use svn to clone remote svn to local svn repo (on error, keep local svn repo, reuse/resume after error),
then use git svn to convert local svn to local git repo

2. svn2github should keep temporary files

3. svn2github should exit on error, currently keeps going after RA layer request failed

Rebasing SVN changes
fatal: bad revision 'HEAD'
rev-list --first-parent --pretty=medium HEAD --: command returned error: 128

Traceback (most recent call last):
File "/nix/store/j906j11908l6n2q7mc469i0b8y0l1h39-svn2github/svn2github.py", line 189, in
main()
File "/nix/store/j906j11908l6n2q7mc469i0b8y0l1h39-svn2github/svn2github.py", line 184, in main
sync_github_mirror(args.github_repo, args.cache_dir, new_svn_url=new_svn_url)
File "/nix/store/j906j11908l6n2q7mc469i0b8y0l1h39-svn2github/svn2github.py", line 148, in sync_github_mirror
git_svn_rebase(git_dir)
File "/nix/store/j906j11908l6n2q7mc469i0b8y0l1h39-svn2github/svn2github.py", line 64, in git_svn_rebase
run_git_cmd(["svn", "rebase"], git_dir)
File "/nix/store/j906j11908l6n2q7mc469i0b8y0l1h39-svn2github/svn2github.py", line 34, in run_git_cmd
return proc.run(["git"] + args, check=True, cwd=git_dir, stdin=DEVNULL, stdout=PIPE)
File "/nix/store/fkzla307l4mlcvfyshsrccwl7szihx2z-python3-3.9.6/lib/python3.9/subprocess.py", line 528, in run
raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['git', 'svn', 'rebase']' returned non-zero exit status 1.

the closed-source tool subgit is said to handle this error, maybe reverse engineer with recaf

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.