Bump Gerrit API to 3.8.0-rc4
The `html` call was dropped from `CommentLinkInfo` due to security
concerns [1].
Previously the code tried to extract `link` from `CommentLinkInfo` and
defaulted to `html` if it wasn't found. The `html` call has been
dropped, so we're now excluding elements where `link` returns null.
[1] https://gerrit-review.googlesource.com/c/gerrit/+/351515
Change-Id: I90e1a2ce26cffdc948f9769c49bb15a4efdbaf4e
diff --git a/build.sbt b/build.sbt
index 9e5666c..1c2f7be 100644
--- a/build.sbt
+++ b/build.sbt
@@ -1,6 +1,6 @@
enablePlugins(GitVersioning)
-val gerritApiVersion = "3.6.0-rc0"
+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 6adb617..08843fd 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
@@ -46,10 +46,9 @@
val nameKey = Project.nameKey(cacheKey.projectName)
val commentInfoList: Seq[CommentLinkInfo] =
if(config.isExtractIssues) projectCache.get(nameKey).asScala.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))
+ )
use(gitRepositoryManager.openRepository(nameKey)) { repo =>
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 24ba6fe..b89bf5e 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}