<commit_before>package org.http4s.sbt

import com.github.tkawachi.doctest.DoctestPlugin.autoImport._
import com.typesafe.sbt.SbtGit.git
import com.typesafe.sbt.git.JGit
import com.typesafe.tools.mima.plugin.MimaKeys._
import de.heikoseeberger.sbtheader.{License, LicenseStyle}
import de.heikoseeberger.sbtheader.HeaderPlugin.autoImport._
import explicitdeps.ExplicitDepsPlugin.autoImport.unusedCompileDependenciesFilter
import org.portablescala.sbtplatformdeps.PlatformDepsPlugin.autoImport._
import sbt.Keys._
import sbt._
import org.typelevel.sbt.gha.GenerativeKeys._
import org.typelevel.sbt.gha.GitHubActionsKeys._
import org.typelevel.sbt.gha.JavaSpec

object Http4sPlugin extends AutoPlugin {
  object autoImport {
    val isCi = settingKey[Boolean]("true if this build is running on CI")
    val http4sApiVersion = settingKey[(Int, Int)]("API version of http4s")
  }
  import autoImport._

  override def trigger = allRequirements

  override def requires = Http4sOrgPlugin

  val scala_213 = "2.13.8"
  val scala_212 = "2.12.16"
  val scala_3 = "3.1.3"

  override lazy val globalSettings = Seq(
    isCi := githubIsWorkflowBuild.value
  )

  override lazy val buildSettings = Seq(
    // Many steps only run on one build. We distinguish the primary build from
    // secondary builds by the Travis build number.
    http4sApiVersion := {
      version.value match {
        case VersionNumber(Seq(major, minor, _*), _, _) =>
          (major.toInt, minor.toInt)
      }
    }
  )

  override lazy val projectSettings: Seq[Setting[_]] = Seq(
    headerSources / excludeFilter := HiddenFileFilter,
    doctestTestFramework := DoctestTestFramework.Munit,
  )

  def extractApiVersion(version: String) = {
    val VersionExtractor = """(\d+)\.(\d+)[-.].*""".r
    version match {
      case VersionExtractor(major, minor) => (major.toInt, minor.toInt)
    }
  }

  def extractDocsPrefix(version: String) =
    extractApiVersion(version).productIterator.mkString("/v", ".", "")

  def latestPerMinorVersion(file: File): Map[(Long, Long), VersionNumber] = {
    def majorMinor(v: VersionNumber) = v match {
      case VersionNumber(Seq(major, minor, _), _, _) =>
        Some((major, minor))
      case _ =>
        None
    }

    // M before RC before final
    def patchSortKey(v: VersionNumber) = v match {
      case VersionNumber(Seq(_, _, patch), Seq(q), _) if q.startsWith("M") =>
        (patch, 0L, q.drop(1).toLong)
      case VersionNumber(Seq(_, _, patch), Seq(q), _) if q.startsWith("RC") =>
        (patch, 1L, q.drop(2).toLong)
      case VersionNumber(Seq(_, _, patch), Seq(), _) => (patch, 2L, 0L)
      case _ => (-1L, -1L, -1L)
    }

    JGit(file).tags
      .collect {
        case ref if ref.getName.startsWith("refs/tags/v") =>
          VersionNumber(ref.getName.substring("refs/tags/v".size))
      }
      .foldLeft(Map.empty[(Long, Long), VersionNumber]) { case (m, v) =>
        majorMinor(v) match {
          case Some(key) =>
            val max =
              m.get(key).fold(v)(v0 => Ordering[(Long, Long, Long)].on(patchSortKey).max(v, v0))
            m.updated(key, max)
          case None => m
        }
      }
  }

  object V { // Dependency versions
    // We pull multiple modules from several projects. This is a convenient
    // reference of all the projects we depend on, and hopefully will reduce
    // error-prone merge conflicts in the dependencies below.
    val blaze = "0.15.3"
    val caseInsensitive = "1.3.0"
    val cats = "2.8.0"
    val catsEffect = "3.3.14"
    val catsParse = "0.3.8"
    val circe = "0.14.2"
    val crypto = "0.2.3"
    val cryptobits = "1.3"
    val disciplineCore = "1.5.1"
    val fs2 = "3.3.0"
    val ip4s = "3.2.0"
    val hpack = "1.0.3"
    val javaWebSocket = "1.5.3"
    val jawn = "1.4.0"
    val jawnFs2 = "2.2.0"
    val jnrUnixSocket = "0.38.17"
    val keypool = "0.4.7"
    val literally = "1.1.0"
    val logback = "1.2.6"
    val log4cats = "2.4.0"
    val log4s = "1.10.0"
    val munit = "1.0.0-M6"
    val munitCatsEffect = "2.0.0-M3"
    val munitDiscipline = "2.0.0-M3"
    val netty = "4.1.82.Final"
    val quasiquotes = "2.1.0"
    val scalacheck = "1.16.0"
    val scalacheckEffect = "2.0.0-M2"
    val scalaJavaLocales = "1.4.1"
    val scalaJavaTime = "2.4.0"
    val scodecBits = "1.1.34"
    val slf4j = "1.7.36"
    val treehugger = "0.4.4"
    val twitterHpack = "1.0.2"
    val vault = "3.2.1"
  }

  lazy val blazeCore = "org.http4s" %% "blaze-core" % V.blaze
  lazy val blazeHttp = "org.http4s" %% "blaze-http" % V.blaze
  lazy val caseInsensitive = Def.setting("org.typelevel" %%% "case-insensitive" % V.caseInsensitive)
  lazy val caseInsensitiveTesting =
    Def.setting("org.typelevel" %%% "case-insensitive-testing" % V.caseInsensitive)
  lazy val catsCore = Def.setting("org.typelevel" %%% "cats-core" % V.cats)
  lazy val catsEffect = Def.setting("org.typelevel" %%% "cats-effect" % V.catsEffect)
  lazy val catsEffectStd = Def.setting("org.typelevel" %%% "cats-effect-std" % V.catsEffect)
  lazy val catsEffectLaws = Def.setting("org.typelevel" %%% "cats-effect-laws" % V.catsEffect)<commit_msg>Update vault to 3.3.0 in series/0.23<commit_after>package org.http4s.sbt

import com.github.tkawachi.doctest.DoctestPlugin.autoImport._
import com.typesafe.sbt.SbtGit.git
import com.typesafe.sbt.git.JGit
import com.typesafe.tools.mima.plugin.MimaKeys._
import de.heikoseeberger.sbtheader.{License, LicenseStyle}
import de.heikoseeberger.sbtheader.HeaderPlugin.autoImport._
import explicitdeps.ExplicitDepsPlugin.autoImport.unusedCompileDependenciesFilter
import org.portablescala.sbtplatformdeps.PlatformDepsPlugin.autoImport._
import sbt.Keys._
import sbt._
import org.typelevel.sbt.gha.GenerativeKeys._
import org.typelevel.sbt.gha.GitHubActionsKeys._
import org.typelevel.sbt.gha.JavaSpec

object Http4sPlugin extends AutoPlugin {
  object autoImport {
    val isCi = settingKey[Boolean]("true if this build is running on CI")
    val http4sApiVersion = settingKey[(Int, Int)]("API version of http4s")
  }
  import autoImport._

  override def trigger = allRequirements

  override def requires = Http4sOrgPlugin

  val scala_213 = "2.13.8"
  val scala_212 = "2.12.16"
  val scala_3 = "3.1.3"

  override lazy val globalSettings = Seq(
    isCi := githubIsWorkflowBuild.value
  )

  override lazy val buildSettings = Seq(
    // Many steps only run on one build. We distinguish the primary build from
    // secondary builds by the Travis build number.
    http4sApiVersion := {
      version.value match {
        case VersionNumber(Seq(major, minor, _*), _, _) =>
          (major.toInt, minor.toInt)
      }
    }
  )

  override lazy val projectSettings: Seq[Setting[_]] = Seq(
    headerSources / excludeFilter := HiddenFileFilter,
    doctestTestFramework := DoctestTestFramework.Munit,
  )

  def extractApiVersion(version: String) = {
    val VersionExtractor = """(\d+)\.(\d+)[-.].*""".r
    version match {
      case VersionExtractor(major, minor) => (major.toInt, minor.toInt)
    }
  }

  def extractDocsPrefix(version: String) =
    extractApiVersion(version).productIterator.mkString("/v", ".", "")

  def latestPerMinorVersion(file: File): Map[(Long, Long), VersionNumber] = {
    def majorMinor(v: VersionNumber) = v match {
      case VersionNumber(Seq(major, minor, _), _, _) =>
        Some((major, minor))
      case _ =>
        None
    }

    // M before RC before final
    def patchSortKey(v: VersionNumber) = v match {
      case VersionNumber(Seq(_, _, patch), Seq(q), _) if q.startsWith("M") =>
        (patch, 0L, q.drop(1).toLong)
      case VersionNumber(Seq(_, _, patch), Seq(q), _) if q.startsWith("RC") =>
        (patch, 1L, q.drop(2).toLong)
      case VersionNumber(Seq(_, _, patch), Seq(), _) => (patch, 2L, 0L)
      case _ => (-1L, -1L, -1L)
    }

    JGit(file).tags
      .collect {
        case ref if ref.getName.startsWith("refs/tags/v") =>
          VersionNumber(ref.getName.substring("refs/tags/v".size))
      }
      .foldLeft(Map.empty[(Long, Long), VersionNumber]) { case (m, v) =>
        majorMinor(v) match {
          case Some(key) =>
            val max =
              m.get(key).fold(v)(v0 => Ordering[(Long, Long, Long)].on(patchSortKey).max(v, v0))
            m.updated(key, max)
          case None => m
        }
      }
  }

  object V { // Dependency versions
    // We pull multiple modules from several projects. This is a convenient
    // reference of all the projects we depend on, and hopefully will reduce
    // error-prone merge conflicts in the dependencies below.
    val blaze = "0.15.3"
    val caseInsensitive = "1.3.0"
    val cats = "2.8.0"
    val catsEffect = "3.3.14"
    val catsParse = "0.3.8"
    val circe = "0.14.2"
    val crypto = "0.2.3"
    val cryptobits = "1.3"
    val disciplineCore = "1.5.1"
    val fs2 = "3.3.0"
    val ip4s = "3.2.0"
    val hpack = "1.0.3"
    val javaWebSocket = "1.5.3"
    val jawn = "1.4.0"
    val jawnFs2 = "2.2.0"
    val jnrUnixSocket = "0.38.17"
    val keypool = "0.4.7"
    val literally = "1.1.0"
    val logback = "1.2.6"
    val log4cats = "2.4.0"
    val log4s = "1.10.0"
    val munit = "1.0.0-M6"
    val munitCatsEffect = "2.0.0-M3"
    val munitDiscipline = "2.0.0-M3"
    val netty = "4.1.82.Final"
    val quasiquotes = "2.1.0"
    val scalacheck = "1.16.0"
    val scalacheckEffect = "2.0.0-M2"
    val scalaJavaLocales = "1.4.1"
    val scalaJavaTime = "2.4.0"
    val scodecBits = "1.1.34"
    val slf4j = "1.7.36"
    val treehugger = "0.4.4"
    val twitterHpack = "1.0.2"
    val vault = "3.3.0"
  }

  lazy val blazeCore = "org.http4s" %% "blaze-core" % V.blaze
  lazy val blazeHttp = "org.http4s" %% "blaze-http" % V.blaze
  lazy val caseInsensitive = Def.setting("org.typelevel" %%% "case-insensitive" % V.caseInsensitive)
  lazy val caseInsensitiveTesting =
    Def.setting("org.typelevel" %%% "case-insensitive-testing" % V.caseInsensitive)
  lazy val catsCore = Def.setting("org.typelevel" %%% "cats-core" % V.cats)
  lazy val catsEffect = Def.setting("org.typelevel" %%% "cats-effect" % V.catsEffect)
  lazy val catsEffectStd = Def.setting("org.typelevel" %%% "cats-effect-std" % V.catsEffect)
  lazy val catsEffectLaws = Def.setting("org.typelevel" %%% "cats-effect-laws" % V.catsEffect)
{'fraction_non_alphanumeric': 0.1413413803173367, 'fraction_numerical': 0.03212304098121289, 'mean_word_length': 2.8887206661619986, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 29, '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': '784530', 'n_tokens_mistral': 3836, 'n_tokens_neox': 3714, 'n_words': 828}