开发者

TortoiseSVN client pre-commit hook get repository URL

开发者 https://www.devze.com 2023-01-11 04:29 出处:网络
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 f

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 "";
}
0

精彩评论

暂无评论...
验证码 换一张
取 消