mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-06 13:35:50 +01:00
Skip issue id extraction if the repository has no issues
This commit is contained in:
@@ -16,6 +16,7 @@ import service._
|
|||||||
import WebHookService._
|
import WebHookService._
|
||||||
import org.eclipse.jgit.api.Git
|
import org.eclipse.jgit.api.Git
|
||||||
import util.JGitUtil.CommitInfo
|
import util.JGitUtil.CommitInfo
|
||||||
|
import service.IssuesService.IssueSearchCondition
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides Git repository via HTTP.
|
* Provides Git repository via HTTP.
|
||||||
@@ -110,19 +111,28 @@ class CommitLogHook(owner: String, repository: String, pusher: String, baseUrl:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Retrieve all issue count in the repository
|
||||||
|
val issueCount =
|
||||||
|
countIssue(IssueSearchCondition(state = "open"), Map.empty, false, owner -> repository) +
|
||||||
|
countIssue(IssueSearchCondition(state = "closed"), Map.empty, false, owner -> repository)
|
||||||
|
|
||||||
// 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)
|
||||||
commits.flatMap { commit =>
|
commits.flatMap { commit =>
|
||||||
if(!existIds.contains(commit.id)){
|
if(!existIds.contains(commit.id)){
|
||||||
createIssueComment(commit)
|
if(issueCount > 0) {
|
||||||
|
createIssueComment(commit)
|
||||||
|
}
|
||||||
Some(commit)
|
Some(commit)
|
||||||
} else None
|
} else None
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
commits.flatMap { commit =>
|
commits.flatMap { commit =>
|
||||||
if(!existsCommitId(owner, repository, commit.id)){
|
if(!existsCommitId(owner, repository, commit.id)){
|
||||||
createIssueComment(commit)
|
if(issueCount > 0) {
|
||||||
|
createIssueComment(commit)
|
||||||
|
}
|
||||||
Some(commit)
|
Some(commit)
|
||||||
} else None
|
} else None
|
||||||
}
|
}
|
||||||
@@ -158,10 +168,13 @@ class CommitLogHook(owner: String, repository: String, pusher: String, baseUrl:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// close issues
|
// close issues
|
||||||
val defaultBranch = getRepository(owner, repository, baseUrl).get.repository.defaultBranch
|
if(issueCount > 0) {
|
||||||
if(refName(1) == "heads" && branchName == defaultBranch && command.getType == ReceiveCommand.Type.UPDATE){
|
val defaultBranch = getRepository(owner, repository, baseUrl).get.repository.defaultBranch
|
||||||
git.log.addRange(command.getOldId, command.getNewId).call.asScala.foreach { commit =>
|
if (refName(1) == "heads" && branchName == defaultBranch && command.getType == ReceiveCommand.Type.UPDATE) {
|
||||||
closeIssuesFromMessage(commit.getFullMessage, pusher, owner, repository)
|
git.log.addRange(command.getOldId, command.getNewId).call.asScala.foreach {
|
||||||
|
commit =>
|
||||||
|
closeIssuesFromMessage(commit.getFullMessage, pusher, owner, repository)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user