Tag Archives: assembla

From Assembla to GITHub – Phase 2: Migrate issues, comments and milestone

In my previous blog From Assembla to GITHub – Phase 1: Migrate your SVN repository to GIT I explained how to migrate your SVN repository to GIT and commit it to GITHub.

In this blog I will give some information on how to migrate Assembla issues into your GITHub repository, without losing any data.

Prerequisite

A PHP Web server to run the script

Chapter 1 – Export data from Assembla

From your Assembla console, Tickets->Settings->Export & Import and Export your tickets, this will generate a bak file (they say it is a JSON, but basically is text file with some JSON structure)

Assembla export

Chapter 2 – Import bak file into your GITHub repository

Here comes the fun… There is no easy way to import this file in GITHub, but they have very powerful REST services.

So, I decided to create a PHP script that parses the export file from Assembla and import to GITHub using their services. GITHub has no official API for PHP, but there are several GITHub repositories that are creating them.

I decided to use github-php-client, that, IMHO, has a great structure and flexibility. Unfortunately, these APIs are not fully compliant with the version 3 of GITHub services.

No fear! Is it an open source project? OK, let’s collaborate…

I created a fork of that project and I completed the API fixing the missing pieces for my scope (currently most of my changes have been included into the master, otherwise you can use my fork).

Then a simple PHP script will do the dirty job… The code is shared as open source here.

github import

After few minutes all the issues, comments and milestones were imported into my new GITHub repository!

Note Before starting the import of the file I suggest to test the export file in a dummy project, only after this test I would suggest to try on your official GIT repository. I have no responsibility on the use of this script.

From Assembla to GITHub – Phase 1: Migrate your SVN repository to GIT

I recently migrated my Assembla abap2xlsx to GITHub ( #abap2xlsx is relocating… Welcome to GITHub ) and I would like to share a quick “how to” just in case you want to migrate also your SVN repository to a GIT repository maintaining all the history.

Prerequisite

  • GIT installed on your machine, if you’re using GITHub you can install their Client
  • Having an SVN repository to migrate 

Let’s start our journey

Preface

Unfortunately, I switched to a Windows PC right now, so most of the screen shots and commands are referred to a windows machine, I’ll try to give you the same details also for Mac o Unix/Linux.

Chapter 1 – Prepare for migration

The first step is to prepare everything in order to have a smooth migration, in this case we need to create a file with the list of all the contributors of the SVN project, this file will be used in the next step to match users in repository history.

Using your console/shell move into the root of your SVN project

If you’re not in a windows machine

svn log -q | awk -F ‘|’ ‘/^r/ {sub(“^ “, “”, $2); sub(” $”, “”, $2); print $2″ = “$2” <“$2″>”}’ | sort -u > USERS.txt

On windows you have to install sed – the stream editor, simple copy sed.exe in the current folder (I’ll make this step simple, you can also add sed in your PATH) and then execute

svn log –quiet –xml | sed -n -e “s/<\/\?author>//g” -e “/[<>]/!p” | sort | sed “$!N; /^\(.*\)\n\1$/!P; D” > USERS.txt

The file is the list of all contributors that had made at least a commit to the repository. We need now to edit this file in order to make it like the snipped below, please pay attention to the charset otherwise the next steps will fail (never trust Notepad)

Alessandro Iannacci = Alessandro Iannacci <aiannacci@xxxxx.it>
gregor.wolf = Gregor Wolf <gregor.wolf@xxxxx.com>
IvanFemia = Ivan Femia <ivan.femia@xxxxxx.com>
JOACHIM.WRBA = Ivan Femia <ivan.femia@xxxxxx.com>
Ludek.Vondruska = Ludek Vondruska <Ludek.Vondruska@xxxxxx.cz>
p491969 = Ivan Femia <ivan.femia@xxxxx.com>
stefan_schmoecker = Stefan Schmöcker <schmoecker@xxxxxx.de>
Tomek Mackowski = Tomek Mackowski <tmackowski@xxxxx.com>
turnheim = Rene Turnheim <rturnheim@xxxxxx.com>
www-data = Ivan Femia <ivan.femia@xxxxxx.com>

Chapter 2 – Convert SVN repository

GITHubOpen your GIT shell and start the conversion…

Really easy? No this command depends on your SVN structure, so it depends on the TRUNK, BRANCHES, TAGS folders.

From GIT console move on a directory that you want to use a working dir and then execute the following command:

git svn clone [SVN repository URL] -A USERS.txt –stdlayout ~/temp

on a Windows machine I suggest to use /temp instead of ~/temp

This command it’s great  if you have a standard SVN layout, with all the three SVN folders; in my case, for example, I had only the trunk as a root so I executed

git svn clone [SVN repository URL] -A USERS.txt –trunk=/trunk /temp

For more information on git svn command please refer to the official documentation

Chapter 3 – Convert svn:ignore to .gitignore

From the GIT console execute this simple steps

cd temp
git svn show-ignore > .gitignore
git add .gitignore
git commit -m ‘Convert svn:ignore properties to .gitignore.’

It will convert the SVN ignore properties in the GIT ignore and add it to the commit.

Chapter 4 – Create the bare repository

Now we need to create our bare repository (.git folder) that will be imported in our Code Repository (e.g. GITHub)

git init –bare ~/your_project_name.git
cd ~/your_project_name.git
git symbolic-ref HEAD refs/heads/trunk

push the content into this bare repository

cd ~/temp
git remote add bare ~/your_project_name.git
git config remote.bare.push ‘refs/remotes/*:refs/heads/*’
git push bare

and link the trunk as master of the git bare

cd ~/new-bare.git
git branch -m trunk master

Chapter 5 – Gran finale: import into your Code Repository

You are now ready to import the .git bare folder into you git repository (in this case GITHub). Make sure that you have created a repository on GITHub with the same name of your bare folder.

cd your_project_name.git
git push –mirror https://github.com/your_user_name/your_project_name.git

and delete temporary folder

cd ..
rm -rf your_project_name.git

Epilogue – Enjoy

Enjoy GITHub!

In the next blog I will describe how to import issues, comments and milestone from Assembla to GITHub.