Add testcases for JGitUtil
1 parent 2cf2ada commit 02f12d40f00330c9cd56ccc31292c0b580adac7a
@Naoki Takezoe Naoki Takezoe authored on 23 Dec 2018
Showing 8 changed files
View
15
project/plugins.sbt
scalacOptions ++= Seq("-unchecked", "-deprecation", "-feature")
 
addSbtPlugin("com.geirsson" % "sbt-scalafmt" % "1.5.0")
addSbtPlugin("com.typesafe.sbt" % "sbt-twirl" % "1.3.15")
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.9")
addSbtPlugin("org.scalatra.sbt" % "sbt-scalatra" % "1.0.3")
addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.1.2")
addSbtCoursier
addSbtPlugin("com.geirsson" % "sbt-scalafmt" % "1.5.0")
addSbtPlugin("com.typesafe.sbt" % "sbt-twirl" % "1.3.15")
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.9")
addSbtPlugin("org.scalatra.sbt" % "sbt-scalatra" % "1.0.3")
addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.1.2")
addSbtPlugin("com.typesafe.sbt" % "sbt-license-report" % "1.2.0")
addSbtPlugin("net.virtual-void" % "sbt-dependency-graph" % "0.9.2")
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.5.1")
 
addSbtCoursier
View
40
src/main/scala/gitbucket/core/controller/PullRequestsController.scala
val thresholdTime = System.currentTimeMillis() - (1000 * 60 * 60)
val mailAddresses =
context.loginAccount.map(x => Seq(x.mailAddress) ++ getAccountExtraMailAddresses(x.userName)).getOrElse(Nil)
 
val branches = JGitUtil
.getBranches(
owner = repository.owner,
name = repository.name,
defaultBranch = repository.repository.defaultBranch,
origin = repository.repository.originUserName.isEmpty
)
.filter { x =>
x.mergeInfo.map(_.ahead).getOrElse(0) > 0 && x.mergeInfo.map(_.behind).getOrElse(0) == 0 &&
x.commitTime.getTime > thresholdTime &&
mailAddresses.contains(x.committerEmailAddress)
}
.sortBy { br =>
(br.mergeInfo.isEmpty, br.commitTime)
}
.map(_.name)
.reverse
val branches =
using(Git.open(getRepositoryDir(repository.owner, repository.name))) {
git =>
JGitUtil
.getBranches(
git = git,
defaultBranch = repository.repository.defaultBranch,
origin = repository.repository.originUserName.isEmpty
)
.filter { x =>
x.mergeInfo.map(_.ahead).getOrElse(0) > 0 && x.mergeInfo.map(_.behind).getOrElse(0) == 0 &&
x.commitTime.getTime > thresholdTime &&
mailAddresses.contains(x.committerEmailAddress)
}
.sortBy { br =>
(br.mergeInfo.isEmpty, br.commitTime)
}
.map(_.name)
.reverse
}
 
val targetRepository = (for {
parentUserName <- repository.repository.parentUserName
parentRepoName <- repository.repository.parentRepositoryName
View
src/main/scala/gitbucket/core/controller/RepositoryViewerController.scala
View
src/main/scala/gitbucket/core/controller/api/ApiRepositoryBranchControllerBase.scala
View
src/main/scala/gitbucket/core/util/JGitUtil.scala
View
src/main/twirl/gitbucket/core/repo/commits.scala.html
View
src/test/scala/gitbucket/core/util/GitSpecUtil.scala
View
src/test/scala/gitbucket/core/util/JGitUtilSpec.scala