Merge branch 'stable-3.4' * stable-3.4: Fix broken tests Bump up scala to 2.11.12 Bump Guice to v5.0.x as in Gerrit stable-3.4 Upgrade Gerrit API to 3.3.3 Upgrade Gerrit API to 3.3.2 Set Gerrit API to 3.3.1-SNAPSHOT Change-Id: I2e78a1180666d4a86ec1230b03f43aefc4b5b066
diff --git a/build.sbt b/build.sbt index 55edb29..b6fb497 100644 --- a/build.sbt +++ b/build.sbt
@@ -14,13 +14,13 @@ resolvers += Resolver.mavenLocal, version := gerritApiVersion, - scalaVersion := "2.11.8", + scalaVersion := "2.11.12", libraryDependencies ++= Seq( "io.fabric8" % "gitective-core" % "0.9.54" exclude ("org.eclipse.jgit", "org.eclipse.jgit"), - "com.google.inject" % "guice" % "4.2.3" % Provided, + "com.google.inject" % "guice" % "5.0.1" % Provided, "com.google.gerrit" % "gerrit-plugin-api" % gerritApiVersion % Provided withSources(), "com.google.code.gson" % "gson" % "2.8.5" % Provided, "joda-time" % "joda-time" % "2.9.9", @@ -29,7 +29,7 @@ "com.google.gerrit" % "gerrit-acceptance-framework" % gerritApiVersion % Test, "org.bouncycastle" % "bcpg-jdk15on" % "1.61" % Test, "org.scalatest" %% "scalatest" % "3.0.1" % Test, - "net.codingwell" %% "scala-guice" % "4.2.6" % Test), + "net.codingwell" %% "scala-guice" % "5.0.0" % Test), assemblyJarName in assembly := s"$pluginName.jar",
diff --git a/src/test/scala/com/googlesource/gerrit/plugins/analytics/test/CommitStatisticsSpec.scala b/src/test/scala/com/googlesource/gerrit/plugins/analytics/test/CommitStatisticsSpec.scala index 8c5eb60..cb000e6 100644 --- a/src/test/scala/com/googlesource/gerrit/plugins/analytics/test/CommitStatisticsSpec.scala +++ b/src/test/scala/com/googlesource/gerrit/plugins/analytics/test/CommitStatisticsSpec.scala
@@ -14,7 +14,8 @@ package com.googlesource.gerrit.plugins.analytics.test -import com.google.gerrit.acceptance.UseLocalDisk +import com.google.gerrit.acceptance.{GitUtil, UseLocalDisk} +import com.google.gerrit.entities.Project import com.googlesource.gerrit.plugins.analytics.CommitInfo import com.googlesource.gerrit.plugins.analytics.common.{CommitsStatistics, Statistics} import org.scalatest.{FlatSpec, Inside, Matchers} @@ -107,8 +108,12 @@ } } - it should "split merge commits and non-merge commits" in new TestEnvironment { - val clonedRepo = testFileRepository.gitClone + it should "split merge commits and non-merge commits" in { + val newProjectKey: Project.NameKey = daemonTest.newProject(testSpecificRepositoryName, true) + val repository = daemonTest.getRepository(newProjectKey) + val clonedRepo = GitUtil.newTestRepository(repository).gitClone + val stats = new Statistics(newProjectKey, commitsStatisticsNoCache) + val firstNonMerge = clonedRepo.commitFile("file1.txt", "line1\nline2\n") val merge = clonedRepo.mergeCommitFile("file1.txt", "line1\nline2\nline3") val nonMerge = clonedRepo.commitFiles(
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 332c733..2feb82d 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
@@ -17,17 +17,15 @@ import java.io.File import java.util.{Date, UUID} -import com.google.gerrit.acceptance.{AbstractDaemonTest, GitUtil} +import com.google.gerrit.acceptance.{AbstractDaemonTest, GitUtil, _} import com.google.gerrit.entities.Project -import com.google.gerrit.extensions.annotations.PluginName import com.google.gerrit.extensions.client.SubmitType -import com.google.gerrit.acceptance._ import com.google.gerrit.extensions.restapi.RestApiModule -import com.google.gerrit.server.project.{ProjectConfig, ProjectState} import com.google.gerrit.server.project.ProjectResource.PROJECT_KIND +import com.google.gerrit.server.project.ProjectState import com.google.inject.AbstractModule -import com.googlesource.gerrit.plugins.analytics.{AnalyticsConfig, ContributorsResource} import com.googlesource.gerrit.plugins.analytics.common.CommitsStatisticsCache +import com.googlesource.gerrit.plugins.analytics.{AnalyticsConfig, ContributorsResource} import org.eclipse.jgit.api.MergeCommand.FastForwardMode import org.eclipse.jgit.api.{Git, MergeResult} import org.eclipse.jgit.internal.storage.file.FileRepository @@ -80,7 +78,7 @@ testFileRepository = GitUtil.newTestRepository(fileRepository) } - private def testSpecificRepositoryName = "git-test-case-" + UUID.randomUUID().toString + protected def testSpecificRepositoryName = "git-test-case-" + UUID.randomUUID().toString implicit class PimpedGitRepository(repo: TestFileRepository) { @@ -151,9 +149,9 @@ AbstractDaemonTest.temporaryFolder.create() tempDataDir.create() - def newProject(nameSuffix: String) = { + def newProject(nameSuffix: String, emptyCommit: Boolean = false) = { resourcePrefix = "" - super.createProjectOverAPI(nameSuffix, allProjects, false, SubmitType.MERGE_IF_NECESSARY) + super.createProjectOverAPI(nameSuffix, allProjects, emptyCommit, SubmitType.MERGE_IF_NECESSARY) } def reloadProject(projectName: Project.NameKey): Option[ProjectState] = {
diff --git a/src/test/scala/com/googlesource/gerrit/plugins/analytics/test/UserActivitySummarySpec.scala b/src/test/scala/com/googlesource/gerrit/plugins/analytics/test/UserActivitySummarySpec.scala index 3ecaa36..a5a5e10 100644 --- a/src/test/scala/com/googlesource/gerrit/plugins/analytics/test/UserActivitySummarySpec.scala +++ b/src/test/scala/com/googlesource/gerrit/plugins/analytics/test/UserActivitySummarySpec.scala
@@ -1,6 +1,7 @@ package com.googlesource.gerrit.plugins.analytics.test -import com.google.gerrit.acceptance.UseLocalDisk +import com.google.gerrit.acceptance.{GitUtil, UseLocalDisk} +import com.google.gerrit.entities.Project import com.googlesource.gerrit.plugins.analytics.UserActivitySummary import com.googlesource.gerrit.plugins.analytics.common.AggregationStrategy.EMAIL import com.googlesource.gerrit.plugins.analytics.common.{Statistics, TestUtils} @@ -14,7 +15,9 @@ val personEmail = "aCommitter@aCompany.com" // we want merge and non-merge commits to be authored by same person, so that they can be aggregated together - val cloneRepo = testFileRepository.gitClone + val newProjectKey: Project.NameKey = daemonTest.newProject(testSpecificRepositoryName, true) + val repository = daemonTest.getRepository(newProjectKey) + val cloneRepo = GitUtil.newTestRepository(repository).gitClone getRepoOwnedByPerson(personEmail, repo = cloneRepo) val personIdent = newPersonIdent("aPerson", personEmail) @@ -22,8 +25,8 @@ cloneRepo.mergeCommitFile("anotherFile.txt", "some other content", author = personIdent, committer = personIdent) cloneRepo.push - val aggregatedCommits = aggregateBy(EMAIL) - val summary = UserActivitySummary.apply(new Statistics(fileRepositoryName, commitsStatisticsNoCache))(aggregatedCommits.head) + val aggregatedCommits = aggregateBy(EMAIL)(repository) + val summary = UserActivitySummary.apply(new Statistics(newProjectKey, commitsStatisticsNoCache))(aggregatedCommits.head) val nonMergeSummary = summary.head val mergeSummary = summary.drop(1).head