<commit_before>#!/usr/bin/env groovy

if (args.length<2) {
    println "Usage :"
    println "./bump-version.groovy oldVersion newVersion"
    return
}

def oldVersion = args[0]
def newVersion = args[1]

// handle all POMs
println "Handling all pom.xml files..."
int nbPoms = 0
new File(".").eachFileRecurse { File f ->
    if (!f.directory && !f.absolutePath.contains("target") && f.name == "pom.xml") {
        println "replacing in $f.absolutePath..."
        // replace version in pom
        String pomText = f.text
        int nbReplaces = 0
        while (pomText.contains(oldVersion)) {
            pomText = pomText.replaceFirst(oldVersion,newVersion)
            nbReplaces++
        }
        assert "invalid number of replacements in $f.absolutePath", nbReplaces == 1
        f.text = pomText
        println "... done with $f.absolutePath"
        nbPoms++
    }
}

assert nbPoms == 37
println "Replaced versions in $nbPoms pom files"

println "Handling bash scripts..."
["woko", "woko.bat"].each {
    File f = new File("./tooling/src/main/scripts/$it")
    f.text = f.text.replace("-DarchetypeVersion=$oldVersion", "-DarchetypeVersion=$newVersion")
    f.text = f.text.replace("/  " + oldVersion, "/  " + newVersion)
}

println "Handling static VERSION in Woko.class"
File woko = new File("./core/src/main/java/woko/Woko.java")
woko.text = woko.text.replace(oldVersion, newVersion)

println "Done. Version bumped from $oldVersion to $newVersion"<commit_msg>fix bump-version script (more poms to replace)<commit_after>#!/usr/bin/env groovy

if (args.length<2) {
    println "Usage :"
    println "./bump-version.groovy oldVersion newVersion"
    return
}

def oldVersion = args[0]
def newVersion = args[1]

// handle all POMs
println "Handling all pom.xml files..."
int nbPoms = 0
new File(".").eachFileRecurse { File f ->
    if (!f.directory && !f.absolutePath.contains("target") && f.name == "pom.xml") {
        println "replacing in $f.absolutePath..."
        // replace version in pom
        String pomText = f.text
        int nbReplaces = 0
        while (pomText.contains(oldVersion)) {
            pomText = pomText.replaceFirst(oldVersion,newVersion)
            nbReplaces++
        }
        assert "invalid number of replacements in $f.absolutePath", nbReplaces == 1
        f.text = pomText
        println "... done with $f.absolutePath"
        nbPoms++
    }
}

assert nbPoms == 41
println "Replaced versions in $nbPoms pom files"

println "Handling bash scripts..."
["woko", "woko.bat"].each {
    File f = new File("./tooling/src/main/scripts/$it")
    f.text = f.text.replace("-DarchetypeVersion=$oldVersion", "-DarchetypeVersion=$newVersion")
    f.text = f.text.replace("/  " + oldVersion, "/  " + newVersion)
}

println "Handling static VERSION in Woko.class"
File woko = new File("./core/src/main/java/woko/Woko.java")
woko.text = woko.text.replace(oldVersion, newVersion)

println "Done. Version bumped from $oldVersion to $newVersion"
{'fraction_non_alphanumeric': 0.14074571716493114, 'fraction_numerical': 0.0053745381256298285, 'mean_word_length': 2.9601063829787235, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6495941', 'n_tokens_mistral': 1012, 'n_tokens_neox': 962, 'n_words': 245}