Merge branch 'stable-3.7' into stable-3.8
* stable-3.7:
Use orNull instead of explicit null default
Fix IterableOnce foreach deprecation warning
Fix array splat deprecation warning
Fix .toStream deprecation warning
Fix deprecated `l` for Longs
Remove use of deprecated JavaConverters class
Fix TraversableOnce deprecation warnings
Fix procedure syntax deprecation warnings
Fix reflective structural type access warning
Fix unable to check type warnings
Fix override without parameter list warning
Update Scala to 2.13.10
Bump scalatest to 3.2.16
Fix feature warnings
Bump sbt to 1.8.3
Add gitignore entries
Set Gerrit API to v3.7.0-rc3
Set Gerrit to v3.6.0-rc0
Change-Id: I3d5b19db244e9a15e4372b257c6ea2764271d150
diff --git a/build.sbt b/build.sbt
index 6f5750d..5203e12 100644
--- a/build.sbt
+++ b/build.sbt
@@ -1,6 +1,6 @@
enablePlugins(GitVersioning)
-val gerritApiVersion = "3.7.0-rc3"
+val gerritApiVersion = "3.8.0-rc4"
val pluginName = "analytics"
diff --git a/src/main/scala/com/googlesource/gerrit/plugins/analytics/common/CommitsStatisticsLoader.scala b/src/main/scala/com/googlesource/gerrit/plugins/analytics/common/CommitsStatisticsLoader.scala
index e4dbe11..e95eef6 100644
--- a/src/main/scala/com/googlesource/gerrit/plugins/analytics/common/CommitsStatisticsLoader.scala
+++ b/src/main/scala/com/googlesource/gerrit/plugins/analytics/common/CommitsStatisticsLoader.scala
@@ -47,10 +47,9 @@
val nameKey = Project.nameKey(cacheKey.projectName)
val commentInfoList: Seq[CommentLinkInfo] =
if(config.isExtractIssues) projectCache.get(nameKey).toScala.toList.flatMap(_.getCommentLinks.asScala) else Seq.empty
- val replacers = commentInfoList.map(info =>
- Replacer(
- info.`match`.r,
- Option(info.link).getOrElse(info.html)))
+ val replacers = commentInfoList.flatMap(info =>
+ Option(info.link).map(link => Replacer(info.`match`.r, link))
+ )
Using.Manager { use =>
val repo = use(gitRepositoryManager.openRepository(nameKey))
diff --git a/src/test/scala/com/googlesource/gerrit/plugins/analytics/test/CommitStatisticsCommentLinkSpec.scala b/src/test/scala/com/googlesource/gerrit/plugins/analytics/test/CommitStatisticsCommentLinkSpec.scala
index 28c5ebe..53593e1 100644
--- a/src/test/scala/com/googlesource/gerrit/plugins/analytics/test/CommitStatisticsCommentLinkSpec.scala
+++ b/src/test/scala/com/googlesource/gerrit/plugins/analytics/test/CommitStatisticsCommentLinkSpec.scala
@@ -15,7 +15,6 @@
package com.googlesource.gerrit.plugins.analytics.test
import com.google.gerrit.acceptance.UseLocalDisk
-import com.google.gerrit.extensions.api.projects.CommentLinkInfo
import com.google.gerrit.server.git.GitRepositoryManager
import com.googlesource.gerrit.plugins.analytics.IssueInfo
import com.googlesource.gerrit.plugins.analytics.common.{CommitsStatistics, Statistics}
@@ -29,14 +28,6 @@
@UseLocalDisk
class CommitStatisticsCommentLinkSpec extends AnyFlatSpecLike with GerritTestDaemon with TestCommitStatisticsNoCache with Matchers with Inside {
- def createCommentLinkInfo(pattern: String, link: Option[String] = None, html: Option[String] = None) = {
- val info = new CommentLinkInfo
- info.`match` = pattern
- info.link = link.orNull
- info.html = html.orNull
- info
- }
-
class TestEnvironment(val repo: Repository = fileRepository) {
lazy val stats = new Statistics(fileRepositoryName, commitsStatisticsNoCache)
testFileRepository.commitFile("project.config",
diff --git a/src/test/scala/com/googlesource/gerrit/plugins/analytics/test/GerritTestDaemon.scala b/src/test/scala/com/googlesource/gerrit/plugins/analytics/test/GerritTestDaemon.scala
index abb155e..4d0df87 100644
--- a/src/test/scala/com/googlesource/gerrit/plugins/analytics/test/GerritTestDaemon.scala
+++ b/src/test/scala/com/googlesource/gerrit/plugins/analytics/test/GerritTestDaemon.scala
@@ -140,6 +140,7 @@
}
}
+@UseLocalDisk
@TestPlugin(
name = "analytics",
sysModule = "com.googlesource.gerrit.plugins.analytics.test.GerritTestDaemon$TestModule"
@@ -160,7 +161,10 @@
}
def getRepository(projectName: Project.NameKey): FileRepository =
- repoManager.openRepository(projectName).asInstanceOf[FileRepository]
+ repoManager.openRepository(projectName) match {
+ case repository: FileRepository => repository
+ case repository => throw new IllegalStateException(s"Expected 'FileRepository', got ${repository.getClass.getName}")
+ }
def adminAuthor = admin.newIdent