Fix #247 servlet.CommitLogHook.onPostReceive takes minutes

When pushing tags, command.getOldId value is
“0000000000000000000000000000000000000000”.
So, can not get commit logs.
This commit is contained in:
kunigaku
2014-03-18 22:51:15 +09:00
parent 61e28146fb
commit 6e0fb95ac3

View File

@@ -99,12 +99,16 @@ class CommitLogHook(owner: String, repository: String, pusher: String, baseUrl:
using(Git.open(Directory.getRepositoryDir(owner, repository))) { git =>
commands.asScala.foreach { command =>
logger.debug(s"commandType: ${command.getType}, refName: ${command.getRefName}")
val commits = command.getType match {
case ReceiveCommand.Type.DELETE => Nil
case _ => JGitUtil.getCommitLog(git, command.getOldId.name, command.getNewId.name)
}
val refName = command.getRefName.split("/")
val branchName = refName.drop(2).mkString("/")
val commits = if (refName(1) == "tags") {
Nil
} else {
command.getType match {
case ReceiveCommand.Type.DELETE => Nil
case _ => JGitUtil.getCommitLog(git, command.getOldId.name, command.getNewId.name)
}
}
// Extract new commit and apply issue comment
val newCommits = if(commits.size > 1000){