I want to create a pre-commit hook which looks at the URL I am committing to. I know that I can get access to the files on the file开发者_C百科 system that they are committing, but is it possible to figure out where you're committing to?
I ended up extracting it from the .svn folder in the current working directory.
var httpAddress = getHttpAddress(WScript.Arguments(3));
function getHttpAddress(currentWorkingDirectory) {
var entriesFile = currentWorkingDirectory + "\\.svn\\entries";
var fso = new ActiveXObject("Scripting.FileSystemObject");
var file = fso.OpenTextFile(entriesFile, 1);
var line = file.ReadAll();
file.Close();
var pieces = line.split('\n');
for (var idx = 0; idx < pieces.length; idx++) {
//pretty cheap, but we just loop till we find a line that looks like a url
if (pieces[idx].substr(0, 7) == "http://") { return pieces[idx]; }
}
return "";
}
精彩评论