Created
March 12, 2012 13:03
-
-
Save JanGorman/2021708 to your computer and use it in GitHub Desktop.
Link svn:externals in a git svn clone
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Run from the root path of your git-svn clone as | |
// node git-svn-externals.js | |
var exec = require('child_process').exec, | |
celeri = require('celeri'), | |
_ = require('underscore') | |
; | |
var spinner = celeri.loading('Finding svn externals. This will take a couple of minutes. '); | |
exec("git svn show-externals | grep -vE '#|^$'", function(err, stdout, stderr) { | |
if (!err) { | |
var lines = _.compact(stdout.split("\n")); | |
_.each(lines, function(line) { | |
var pathAndName = line.split(' '); | |
if (pathAndName.length > 1) { | |
if (_.last(pathAndName).indexOf('https') >= 0) { | |
return; | |
}; | |
// Paths come out in the following form: | |
// /a/b/c/../../../d/e/f | |
var index = _.first(pathAndName).indexOf('../') | |
var targetDir = '.' + _.first(pathAndName).substr(0, index); | |
var linkDir = _.first(pathAndName).substr(index); | |
console.log('Linking ' + linkDir + ' into ' + targetDir + ' as ' + _.last(pathAndName)); | |
exec('cd ' + targetDir + ' && ln -s ' + linkDir + ' ' + _.last(pathAndName), function(err, stdout, stderr) { | |
if (err) { | |
console.error('oh noes: ' + err); | |
}; | |
}); | |
}; | |
}); | |
}; | |
spinner.done('Success', true); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment