Skip to content

Instantly share code, notes, and snippets.

@anilsaldhana
Last active August 29, 2015 14:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anilsaldhana/11271541 to your computer and use it in GitHub Desktop.
Save anilsaldhana/11271541 to your computer and use it in GitHub Desktop.
PicketBox-SVN To Git Migration
Followed the steps highlighted in https://wiki.52north.org/bin/view/Documentation/SvnToGitHubMigration
Step:
$> mkdir GITMIGRATION
$> cd GITMIGRATION
Step:
$ svn co https://svn.jboss.org/repos/picketbox/ picketbox
Created users.txt
==========
anil.saldhana@jboss.com = Anil Saldhana <anil.saldhana@jboss.com>
apache = Apache Process
dehort = Derek Horton <dehort@redhat.com>
jbf-portal-adm@jboss.com = JBoss Portal Migration
mmoyses = Marcus Moyses <mmoyses@redhat.com>
pcraveiro = Pedro Silva <psilva@redhat.com>
pskopek = Peter Skopek <pskopek@redhat.com>
pskopek@redhat.com = Peter Skopek <pskopek@redhat.com>
sguilhen@redhat.com = Stefan Guilhen <sguilhen@redhat.com>
tfonteyn = Tom Fonteyn <tfonteyn@redhat.com>
vladimir_v = Vladimir Dosoudil <vdosoudi@redhat.com>
=============
~/GITMIGRATION$ git svn clone --prefix=svn/ -s --no-metadata --authors-file=users.txt https://svn.jboss.org/repos/picketbox/ picketbox/
~/GITMIGRATION/picketbox$ vi createGitTags.sh
=============
#!/bin/sh
# Based on https://github.com/haarg/convert-git-dbic
set -u
set -e
git for-each-ref --format='%(refname)' refs/remotes/svn/tags/* | while read r; do
tag=${r#refs/remotes/svn/tags/}
sha1=$(git rev-parse "$r")
commiterName="$(git show -s --pretty='format:%an' "$r")"
commiterEmail="$(git show -s --pretty='format:%ae' "$r")"
commitDate="$(git show -s --pretty='format:%ad' "$r")"
# Print the commit subject and body separated by a newline
git show -s --pretty='format:%s%n%n%b' "$r" | \
env GIT_COMMITTER_EMAIL="$commiterEmail" GIT_COMMITTER_DATE="$commitDate" GIT_COMMITTER_NAME="$commiterName" \
git tag -a -m "Tag: ${tag} sha1: ${sha1} using '${commiterName}', '${commiterEmail}' on '${commitDate}'" "$tag" "$sha1"
# Remove the svn/tags/* ref
git update-ref -d "$r"
done
=========
Step:
Run the create tags script
~GITMIGRATION/picketbox $> ./createGitTags.sh
~/GITMIGRATION/picketbox$ git tag -l
3.0.0.Beta1
3.0.0.Beta2
3.0.0.Final
4.0.0-alpha1
4.0.0.Alpha1
4.0.0.Alpha2
4.0.0.Alpha3
4.0.0.Alpha4
4.0.0.Alpha5
4.0.0.Alpha6
4.0.0.Alpha7
4.0.0.Alpha8
4.0.0.Beta1
4.0.0.Beta2
4.0.0.Beta3
4.0.0.Beta4
4.0.0.CR1
4.0.0.Final
4.0.1
4.0.10.Final
4.0.11.Final
4.0.12.Final
4.0.13.Final
4.0.14.Final
4.0.15.Final
4.0.16.Final
4.0.17.Final
4.0.17.SP1
4.0.17.SP2
4.0.17.SP2@456
4.0.18.Final
4.0.19.Final
4.0.19.SP2
4.0.19.SP3
4.0.19.SP3@523
4.0.19.SP4
4.0.19.SP5
4.0.19.SP6
4.0.2.final
4.0.20.Beta2
4.0.20.Beta3
4.0.20.Beta4
4.0.20.Final
4.0.21.Beta1
4.0.21.Beta2
4.0.3
4.0.5.Final
4.0.6.Beta1
4.0.6.Beta2
4.0.6.final
4.0.7.Final
4.0.8.Final
4.0.9.Final
Step:
Deleted the file createGitTags.sh
Step:
Deal with the branches
~/GITMIGRATION/picketbox$ git branch -a
* master
remotes/svn/4.0.14.Final-bz-1005418
remotes/svn/4.0.14.Final_BZ_908845
remotes/svn/4.0.15.Final-JBPAPP6-1704
remotes/svn/4.0.16.Final_BZ_901138
remotes/svn/4.0.17.Final-BZ_982539
remotes/svn/4.0.17.Final-bz-1073646
remotes/svn/4.0.17.SP2-bz-1022318
remotes/svn/4.0.17.SP2-bz-1089068
remotes/svn/4.0.9.Final-JBPAPP-10088
remotes/svn/4.0.9.Final-bz-914821
remotes/svn/Branch_3_x
remotes/svn/EAP6plus
remotes/svn/eap62
remotes/svn/trunk
We have to now deal with each branch here
~/GITMIGRATION/picketbox$> vi DealWithBranches.sh
For each relevant branch, we need two git checkout calls as shown below
=================
#this switches to the remote branch
git checkout remotes/svn/4.0.14.Final-bz-1005418
#this creates a local branch from the remote (as it is the active one)
git checkout -b 4.0.14.Final-bz-1005418
....
git checkout remotes/svn/eap62
#this creates a local branch from the remote (as it is the active one)
git checkout -b eap62
=================
./DealWithBranches.sh
Note: checking out 'remotes/svn/4.0.14.Final-bz-1005418'.
You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.
If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:
git checkout -b new_branch_name
HEAD is now at e8125ef... Backporting LDAP referral fix from EAP 6.1.0 [bz-1005418]
....
HEAD is now at a7e1aab... setting next version for development
Switched to a new branch 'eap62'
Step:
NOTE: We are currently on eap62 branch. We need to get on our "master" branch.
~/GITMIGRATION/picketbox$ git status
On branch eap62
Untracked files:
(use "git add <file>..." to include in what will be committed)
.svn/
DealWithBranches.sh
admin/
branches/
commons/
tags/
trunk/
nothing added to commit but untracked files present (use "git add" to track)
anil@localhost:~/GITMIGRATION/picketbox$ git checkout master
Switched to branch 'master'
Copied .gitignore from picketlink project.
~/GITMIGRATION/picketbox$ git add .gitignore
~/GITMIGRATION/picketbox$ git commit -m "Adjust .gitignore"
[master c55744a] Adjust .gitignore
1 file changed, 64 insertions(+)
create mode 100644 .gitignore
Step:
Add a link to the remote repository
~/GITMIGRATION/picketbox$ git remote add origin https://github.com/picketbox/picketbox.git
Step:
Push all refs under refs/heads
~/GITMIGRATION/picketbox$ git push origin --all
Step:
Push all refs under refs/tags
~/GITMIGRATION/picketbox$ git push origin --tags
Also, the PicketBox Commons that was present in https://svn.jboss.org/repos/picketbox/commons/
has been migrated over to https://github.com/picketbox/commons
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment