Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting list of SVN users for Subversion -> Git migration?

Tags:

I've been looking over a few SVN -> Git migrations and they all mention getting a proper users list before migrating, specifically by using the command:

svn log -q | grep -e '^r' | awk 'BEGIN { FS = "|" } ; { print $2 }' | sort | uniq 

I have access to the Ubuntu server hosting the single repository (with 9 projects), but no SVN installation locally. Is it possible to run that command on the server to get the list of usernames? At the moment it just gives back the error:

svn: E155007: '/var/subversion/' is not a working copy 
like image 296
xref Avatar asked Mar 02 '12 21:03

xref


People also ask

Which migration is actually recommended for migration from SVN to Git?

When moving to Git from another version control system like Subversion (SVN), we generally recommend that you perform a "tip migration", which migrates just the latest version of the repository contents, without including history.

What is Git SVN fetch?

DESCRIPTION. git svn is a simple conduit for changesets between Subversion and Git. It provides a bidirectional flow of changes between a Subversion and a Git repository. git svn can track a standard Subversion repository, following the common "trunk/branches/tags" layout, with the --stdlayout option.


2 Answers

Pass the path to the repository as a URL:

svn log -q file:///var/subversion | grep -e '^r' | awk 'BEGIN { FS = "|" } ; { print $2 }' | sort | uniq 

By the way, if you need the list of authors in chronological order of first commit (I found it helpful once when converting from svn to git), you can do the following:

svn log -q -r 1:HEAD url://to/repo | grep '^r' | awk -F'|' '!x[$2]++{print$2}' 
like image 129
Richard Hansen Avatar answered Sep 18 '22 06:09

Richard Hansen


See the instructions below to convert an SVN repository to a git repository

Note: To ONLY see the list of users run line item 1.

CONVERT SVN REPO to GIT REPO

1. Retrieve a list of all Subversion committers

 $ svn log -q https://svn.example.com/repository_name | awk -F '|' '/^r/ {sub("^ ", "", $2); sub(" $", "", $2); print $2" = "$2" <"$2">"}' | sort -u > authors-transform.txt 

That will grab all the log messages, pluck out the usernames, eliminate any duplicate usernames, sort the usernames and place them into a "authors-transform.txt” file. Now edit each line in the file. For example, convert:

username = username <username> 

into this:

 username = Firstname Lastname <[email protected]> 

2. Clone the Subversion repository using git-svn

git svn clone [SVN repo URL] --no-metadata -A authors-transform.txt --stdlayout ~/temp 

3. Convert svn:ignore properties to .gitignore If your svn repo was using svn:ignore properties, you can easily convert this to a .gitignore file using:

cd ~/temp git svn show-ignore > .gitignore git add .gitignore git commit -m 'Convert svn:ignore properties to .gitignore.' 

4. Push repository to a bare git repository First, create a bare repository and make its default branch match svn’s "trunk” branch name.

git init --bare ~/new-bare.git cd ~/new-bare.git git symbolic-ref HEAD refs/heads/trunk  cd ~/temp git remote add bare ~/new-bare.git git config remote.bare.push 'refs/remotes/*:refs/heads/*' git push bare 

You can now safely delete the ~/temp repository.

5. Rename "trunk" branch to "master" Your main development branch will be named "trunk” which matches the name it was in Subversion. You’ll want to rename it to Git’s standard "master” branch using:

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

6. Clean up branches and tags git-svn makes all of Subversions tags into very-short branches in Git of the form "tags/name”. You’ll want to convert all those branches into actual Git tags using:

cd ~/new-bare.git git for-each-ref --format='%(refname)' refs/heads/tags | cut -d / -f 4 | while read ref do    git tag "$ref" "refs/heads/tags/$ref";    git branch -D "tags/$ref"; done 

7. Move bare repository to central remote repository Example of how to move your local bare repository to a gitolite repository:

mv new-bare.git repository_name.git tar czvf repository_name.git.tar.gz repository_name.git/ scp repository_name.git.tar.gz remote_host: ssh remote_host tar xzvf repository_name.git.tar.gz sudo chown -R git:staff repository_name.git/ cd repository_name.git/ find . -type f -exec chmod go= {} \;  # remove group and world permissions find . -type d -exec chmod go= {} \;  # remove group and world permissions cd ../ mv repository_name.git /Users/git/repositories/ 

8. Clone new local copy

mv old-svn-copy old-svn-copy.backup git clone git@remote_host:repository_name.git 

List all unversioned files from your old local svn repository and copy them to the new local git repository:

cd old-svn-copy.backup git clean -dXn  # Using this command because the old copy was a git-svn clone cp example-file.txt ../repository_name/  # copy all files and directories from the list that you need in the new local git repository 

You can now move the local svn copy backup to your trash. It might be a good idea not to empty your trash until your sure everything is working correctly.

9. Done.

Source here

like image 39
Tyler Rafferty Avatar answered Sep 22 '22 06:09

Tyler Rafferty