From bd36517fc1b58028968816d916c265d7a3dd770e Mon Sep 17 00:00:00 2001 From: Roberto Tyley Date: Wed, 14 Dec 2022 08:45:04 +0000 Subject: [PATCH] Support Scala 3 --- build.sbt | 5 +++-- scala-git/src/main/scala/com/madgag/diff/MapDiff.scala | 4 ++-- scala-git/src/main/scala/com/madgag/git/package.scala | 7 ++----- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/build.sbt b/build.sbt index b4609b7..b03e6f8 100644 --- a/build.sbt +++ b/build.sbt @@ -1,14 +1,15 @@ import ReleaseTransformations._ +import Dependencies._ lazy val baseSettings = Seq( scalaVersion := "2.13.10", - crossScalaVersions := Seq(scalaVersion.value), + crossScalaVersions := Seq(scalaVersion.value, "3.2.1"), organization := "com.madgag.scala-git", scmInfo := Some(ScmInfo( url("https://github.com/rtyley/scala-git"), "scm:git:git@github.com:rtyley/scala-git.git" )), - licenses := Seq("Apache-2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0")), + licenses := Seq("Apache-2.0" -> url("https://www.apache.org/licenses/LICENSE-2.0")), scalacOptions ++= Seq("-deprecation", "-unchecked") ) diff --git a/scala-git/src/main/scala/com/madgag/diff/MapDiff.scala b/scala-git/src/main/scala/com/madgag/diff/MapDiff.scala index 11c4882..c9204e2 100644 --- a/scala-git/src/main/scala/com/madgag/diff/MapDiff.scala +++ b/scala-git/src/main/scala/com/madgag/diff/MapDiff.scala @@ -1,6 +1,6 @@ package com.madgag.diff -import com.madgag.scala.collection.decorators.MapDecorator +import com.madgag.scala.collection.decorators._ object MapDiff { def apply[K,V](before: Map[K,V], after: Map[K,V]): MapDiff[K,V] = @@ -20,6 +20,6 @@ case class MapDiff[K, V](beforeAndAfter: Map[BeforeAndAfter, Map[K,V]]) { lazy val unchangedMap: Map[K,V] = beforeAndAfter(Before).view.filterKeys(unchanged).toMap lazy val changedMap: Map[K,Map[BeforeAndAfter, V]] = - changed.map(k => k -> beforeAndAfter.mapV(_(k)).toMap).toMap + changed.map(k => k -> beforeAndAfter.mapV(_(k))).toMap } \ No newline at end of file diff --git a/scala-git/src/main/scala/com/madgag/git/package.scala b/scala-git/src/main/scala/com/madgag/git/package.scala index a233b8d..b2cf67b 100644 --- a/scala-git/src/main/scala/com/madgag/git/package.scala +++ b/scala-git/src/main/scala/com/madgag/git/package.scala @@ -39,9 +39,6 @@ import org.eclipse.jgit.treewalk.TreeWalk import org.eclipse.jgit.treewalk.filter.{AndTreeFilter, TreeFilter} import org.eclipse.jgit.util.FS - - - package object git { implicit class RichByteArray(bytes: Array[Byte]) { @@ -94,7 +91,7 @@ package object git { (revWalk, revWalk.getObjectReader) } - def nonSymbolicRefs = repo.getAllRefs.asScala.values.filterNot(_.isSymbolic) + def nonSymbolicRefs: Iterable[Ref] = repo.getRefDatabase.getRefs.asScala.toSeq.filterNot(_.isSymbolic) } @@ -172,7 +169,7 @@ package object git { implicit class RichRevObject(revObject: RevObject) { lazy val typeString = Constants.typeString(revObject.getType) - def toTree(implicit revWalk: RevWalk): Option[RevTree] = treeOrBlobPointedToBy(revObject).right.toOption + def toTree(implicit revWalk: RevWalk): Option[RevTree] = treeOrBlobPointedToBy(revObject).toOption } val FileModeNames = Map(