[ create a new paste ] login | about

Link: http://codepad.org/14TUDCor    [ raw code | fork ]

C, pasted on May 26:
var Process = loadExtension("qbs.Process");
function gitHash(sourceDirectory){
    var process = new Process()
    var version = "0.1.0"
    var topLevel = sourceDirectory + "/../"
    var gitDir = "--git-dir=" + topLevel + ".git"
    var workTree = "--work-tree=" + topLevel + ".git"
    var base_git_command = [gitDir, workTree]
    var procResult = process.exec("git", [gitDir, workTree, "describe","--always"])
    gitversion = process.readLine()
    print("getVersion")

    error = process.readStdErr()
    print(error)
    print("version is:")
    print(gitversion)

    var commitcount = process.exec("git", base_git_command.concat(["rev-list","HEAD", "--count"]))
    print("commitcount is:")
    commitcountError =  process.readStdErr()
    commitcountLine = process.readLine()
    print(commitcountError)
    print(commitcountLine)

    gitversion = gitversion.replace(/-/g, ".")
    gitversion = gitversion.replace(/g/g, "")
    print(gitversion)
    if (!gitversion) {
        throw "error: " + error + " version: " + gitversion +  "commitcount: " + commitcountError + " commitline: " + commitcountLine
    }
    return gitversion;
}

function gitDate(sourceDirectory, hash){
    print("gitVersion")
    var process = new Process()
    var topLevel = sourceDirectory + "/../"
    var gitDir = "--git-dir=" + topLevel + ".git"
    var workTree = "--work-tree=" + topLevel + ".git"
    var base_git_command = [gitDir, workTree]
    var procResult = process.exec("git", [gitDir, workTree, "show", "-s","--format=%ci", hash])
    date = process.readLine()
    print(date)
    return date;
}

function gitTag(sourceDirectory){
    var process = new Process()
    var version = "0.1.0"
    var topLevel = sourceDirectory + "/../"
    var gitDir = "--git-dir=" + topLevel + ".git"
    var workTree = "--work-tree=" + topLevel + ".git"
    var base_git_command = [gitDir, workTree]
    var procResult = process.exec("git", [gitDir, workTree, "describe","--tags", "--abbrev=0"])
    var tag = process.readLine()
    return tag;
}


Create a new paste based on this one


Comments: