Fix branch name.

This commit is contained in:
takezoe
2013-10-06 19:49:46 +09:00
parent f1476c52e6
commit e457cfb212

View File

@@ -87,7 +87,8 @@ class CommitLogHook(owner: String, repository: String, userName: String, baseURL
commands.asScala.foreach { command => commands.asScala.foreach { command =>
val commits = JGitUtil.getCommitLog(git, command.getOldId.name, command.getNewId.name) val commits = JGitUtil.getCommitLog(git, command.getOldId.name, command.getNewId.name)
val refName = command.getRefName.split("/") val refName = command.getRefName.split("/")
val branchName = refName.drop(2).mkString("/")
// Extract new commit and apply issue comment // Extract new commit and apply issue comment
val newCommits = if(commits.size > 1000){ val newCommits = if(commits.size > 1000){
val existIds = getAllCommitIds(owner, repository) val existIds = getAllCommitIds(owner, repository)
@@ -108,20 +109,21 @@ class CommitLogHook(owner: String, repository: String, userName: String, baseURL
// batch insert all new commit id // batch insert all new commit id
insertAllCommitIds(owner, repository, newCommits.map(_.id)) insertAllCommitIds(owner, repository, newCommits.map(_.id))
// record activity // record activity
if(refName(1) == "heads"){ if(refName(1) == "heads"){
command.getType match { command.getType match {
case ReceiveCommand.Type.CREATE => { case ReceiveCommand.Type.CREATE => {
recordCreateBranchActivity(owner, repository, userName, refName(2)) println(command.getRefName)
recordPushActivity(owner, repository, userName, refName(2), newCommits) recordCreateBranchActivity(owner, repository, userName, branchName)
recordPushActivity(owner, repository, userName, branchName, newCommits)
} }
case ReceiveCommand.Type.UPDATE => recordPushActivity(owner, repository, userName, refName(2), newCommits) case ReceiveCommand.Type.UPDATE => recordPushActivity(owner, repository, userName, branchName, newCommits)
case _ => case _ =>
} }
} else if(refName(1) == "tags"){ } else if(refName(1) == "tags"){
command.getType match { command.getType match {
case ReceiveCommand.Type.CREATE => recordCreateTagActivity(owner, repository, userName, refName(2), newCommits) case ReceiveCommand.Type.CREATE => recordCreateTagActivity(owner, repository, userName, branchName, newCommits)
case _ => case _ =>
} }
} }