<commit_before>#!/usr/bin/env kotlin
import java.io.File
import kotlin.system.exitProcess

/**
 * A script to run locally in order to make a release.
 *
 * You need kotlin 1.3.70+ installed on your machine
 */


if (runCommand("git", "status", "--porcelain").isNotEmpty()) {
  println("Your git repo is not clean. Make sur to stash or commit your changes before making a release")
  exitProcess(1)
}

check(getCurrentVersion().endsWith("-SNAPSHOT")) {
  "Version '${getCurrentVersion()} is not a -SNAPSHOT, check your working directory"
}

check(args.size == 1) {
  "tag.main.kts [version to tag]"
}
val tagVersion = args[0]
val nextSnapshot = getNextSnapshot(tagVersion)


while (true) {
  println("Current version is '${getCurrentVersion()}'.")
  println("Tag '$tagVersion' and bump to $nextSnapshot [y/n]?")

  when (readLine()!!.trim()) {
    "y" -> break
    "n" -> {
      println("Aborting.")
      exitProcess(1)
    }
  }
}

setCurrentVersion(tagVersion)

runCommand("git", "commit", "-a", "-m", "release $tagVersion")
runCommand("git", "tag", "v$tagVersion")

setCurrentVersion(nextSnapshot)
runCommand("git", "commit", "-a", "-m", "version is now $nextSnapshot")

println("Everything is done. Verify everything is ok and type `git push origin main` to trigger the new version.")

fun runCommand(vararg args: String): String {
  val builder = ProcessBuilder(*args)
      .redirectError(ProcessBuilder.Redirect.INHERIT)

  val process = builder.start()
  val ret = process.waitFor()

  val output = process.inputStream.bufferedReader().readText()<commit_msg>Update tag.main.kts<commit_after>#!/usr/bin/env kotlin
import java.io.File
import kotlin.system.exitProcess

/**
 * A script to run locally in order to make a release.
 *
 * You need kotlin 1.3.70+ installed on your machine
 */


if (runCommand("git", "status", "--porcelain").isNotEmpty()) {
  println("Your git repo is not clean. Make sur to stash or commit your changes before making a release")
  exitProcess(1)
}

check(getCurrentVersion().endsWith("-SNAPSHOT")) {
  "Version '${getCurrentVersion()} is not a -SNAPSHOT, check your working directory"
}

check(args.size == 1) {
  "tag.main.kts [version to tag]"
}
val tagVersion = args[0]
val nextSnapshot = getNextSnapshot(tagVersion)


while (true) {
  println("Current version is '${getCurrentVersion()}'.")
  println("Tag '$tagVersion' and bump to $nextSnapshot [y/n]?")

  when (readLine()!!.trim()) {
    "y" -> break
    "n" -> {
      println("Aborting.")
      exitProcess(1)
    }
  }
}

setCurrentVersion(tagVersion)

runCommand("git", "commit", "-a", "-m", "release $tagVersion")
runCommand("git", "tag", "v$tagVersion")

setCurrentVersion(nextSnapshot)
runCommand("git", "commit", "-a", "-m", "version is now $nextSnapshot")

println("Everything is done. Verify everything is ok and push upstream to trigger the new version.")

fun runCommand(vararg args: String): String {
  val builder = ProcessBuilder(*args)
      .redirectError(ProcessBuilder.Redirect.INHERIT)

  val process = builder.start()
  val ret = process.waitFor()

  val output = process.inputStream.bufferedReader().readText()
{'fraction_non_alphanumeric': 0.15227127319257838, 'fraction_numerical': 0.005118362124120281, 'mean_word_length': 4.438260869565218, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, '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': '6052056', 'n_tokens_mistral': 1011, 'n_tokens_neox': 991, 'n_words': 289}