简体   繁体   中英

TortoiseSVN client pre-commit hook get repository URL

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM