Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Checkout a Git clone of an SVN repository in parent folder (See related posts)

Here is a quick executable cmd that you run inside a folder checked out with Subversion. It will clone the repository using Git into the parent folder as <projname>.git

Stick this code into ~/bin/gitify and add ~/bin to your path:

#!/usr/bin/env ruby -wKU

# get svn info location
svnurl = `svn info | grep "^URL:"`.gsub('URL: ','').chomp

# project = basename
project = File.basename(Dir.pwd)

puts cmd = "git-svn clone #{svnurl} ../#{project}.git"

`#{cmd}`

Comments on this post

justinwr posts on Dec 05, 2007 at 15:33
I reworked this to try and fit it into a shell alias, but I believe running `svn status` is killing it somewhere... but anyway, here you go for anyone else that wants a go at it!

ruby -wKUe 'p=%{git-svn clone }+`svn info`.to_a[1][5..-2]+%{ ../}+File.basename(Dir.pwd)+%{.git};`#{c}`;'

justinwr posts on Dec 05, 2007 at 15:35
Whoops, that last `#{c}` should be a `#{p}`...
justinwr posts on Dec 05, 2007 at 21:06
...and we have a winner!

alias testme="ruby -wKUe 'a=%{git-svn};b=%{clone};c=%{`svn info`}.to_s.to_a[1][5..-2];d=%{../}+File.basename(Dir.pwd)+%{.git};system(a,b,c,d);'"

You need to create an account or log in to post comments to this site.


Click here to browse all 5140 code snippets

Related Posts