Home > Uncategorized > From git-svn to plain git

From git-svn to plain git

Here is my script to prepare a git-svn repository to be pushed on a plain git repository. It create local branches from svn branches and local tags from svn tags.

#! /usr/bin/python
from subprocess import *
output = Popen(["git", "branch", "-rl"], stdout=PIPE).communicate()[0]
for b in output.split("\n"):
    b=b.strip()
    if b != "trunk" and len(b)>0:
        ref="remotes/"+b
        parent=Popen(["git", "log", "-n1", "--pretty=%P", ref], stdout=PIPE).communicate()[0]
        parent=parent.split()[-1]
        if b.startswith("tags/"):
            tag=b[len("tags/"):]
            message=Popen(["git", "log", "-n1", "--pretty=%B", ref], stdout=PIPE).communicate()[0]
            message=message.strip()
            call(["git", "tag", "-m", message, tag, parent])
        else:
            call(["git", "branch", b, parent])
Advertisements
Tags:
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: