From 6e0fb95ac38a3a9073e4430460bd839eb5d24360 Mon Sep 17 00:00:00 2001 From: kunigaku Date: Tue, 18 Mar 2014 22:51:15 +0900 Subject: [PATCH] Fix #247 servlet.CommitLogHook.onPostReceive takes minutes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When pushing tags, command.getOldId value is “0000000000000000000000000000000000000000”. So, can not get commit logs. --- src/main/scala/servlet/GitRepositoryServlet.scala | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/main/scala/servlet/GitRepositoryServlet.scala b/src/main/scala/servlet/GitRepositoryServlet.scala index bb19aa54e..60a5224dc 100644 --- a/src/main/scala/servlet/GitRepositoryServlet.scala +++ b/src/main/scala/servlet/GitRepositoryServlet.scala @@ -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){