Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions build.mill
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ import mill.scalalib.publish.{Developer, License, PomSettings, VersionControl}
import org.typelevel.scalacoptions.ScalacOptions._
import org.typelevel.scalacoptions.{ScalaVersion, ScalacOptions}

object `mill-git` extends Cross[MillGitCross]("0.12.0", "0.13.0-M0")
object `mill-git` extends Cross[MillGitCross]("0.12.0", "0.13.0-M0-93-a6992e")
trait MillGitCross extends Cross.Module[String] with StyleModule with GitVersionedPublishModule {
val millVersion = crossValue
override def scalaVersion = millBinaryVersion(millVersion) match {
case "0.11" => "2.13.16"
case "0.13" => "3.6.3"
override def scalaVersion = millVersion match {
case millVersion if millVersion.startsWith("0.12") => "2.13.16"
case millVersion if millVersion.startsWith("0.13") => "3.6.3"
}
override def scalacOptions = super.scalacOptions() ++ ScalacOptions.tokensForVersion(
ScalaVersion.unsafeFromString(scalaVersion()),
Expand Down Expand Up @@ -62,6 +62,6 @@ trait MillGitCross extends Cross.Module[String] with StyleModule with GitVersion

def millBinaryVersion(millVersion: String) = millVersion match {
case version if version.startsWith("0.12") => "0.11" // 0.12.x is binary compatible with 0.11.x
case version if version.startsWith("0.13") => "0.13"
case version if version.startsWith("0.13") => "0.13.0-M0"
case _ => throw new IllegalArgumentException(s"Unsupported Mill version: $millVersion")
}
14 changes: 6 additions & 8 deletions mill-git/src/com/goyeau/mill/git/GitVersionModule.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.goyeau.mill.git

import mill.*
import mill.api.Result.{Exception as MillException, OuterStack, Success as MillSuccess}
import mill.api.Result
import mill.Task.workspace
import mill.define.{Command, Discover, ExternalModule}
import org.eclipse.jgit.api.Git
Expand All @@ -24,7 +24,7 @@ object GitVersionModule extends ExternalModule {
val describeResult = Try(git.describe().setTags(true).setMatch("v[0-9]*").setAlways(true).call())

describeResult match {
case TryFailure(_) => MillSuccess(uncommitted())
case TryFailure(_) => Result.Success(uncommitted())
case TrySuccess(description) =>
val taggedRegex = """v(\d.*?)(?:-(\d+)-g([\da-f]+))?""".r
val untaggedRegex = """([\da-f]+)""".r
Expand All @@ -38,13 +38,11 @@ object GitVersionModule extends ExternalModule {
if (isDirty) s"-${distance.toInt + 1}-${uncommitted()}"
else s"-$distance-${hash.take(hashLength)}$snapshotSuffix"
}
MillSuccess(s"$tag$distanceHash")
Result.Success(s"$tag$distanceHash")
case untaggedRegex(hash) =>
if (isDirty) MillSuccess(uncommitted())
else MillSuccess(s"${hash.take(hashLength)}$snapshotSuffix")
case _ =>
val exception = new IllegalStateException(s"Unexpected git describe output: $description")
MillException(exception, new OuterStack(exception.getStackTrace.toIndexedSeq))
if (isDirty) Result.Success(uncommitted())
else Result.Success(s"${hash.take(hashLength)}$snapshotSuffix")
case _ => Result.Failure(s"Unexpected git describe output: $description")
}
}
}
Expand Down