mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-06 05:25:50 +01:00
Improve the commit hook to add commit messages to the issue comment.
This commit is contained in:
@@ -154,6 +154,39 @@ object JGitUtil {
|
||||
commits
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the commit list between two revisions.
|
||||
*
|
||||
* @param git the Git object
|
||||
* @param from the from revision
|
||||
* @param to the to revision
|
||||
* @return the commit list
|
||||
*/
|
||||
def getCommitLog(git: Git, from: String, to: String): List[CommitInfo] = {
|
||||
@scala.annotation.tailrec
|
||||
def getCommitLog(i: java.util.Iterator[RevCommit], logs: List[CommitInfo]): List[CommitInfo] =
|
||||
i.hasNext match {
|
||||
case true => {
|
||||
val revCommit = i.next
|
||||
if(revCommit.name == from){
|
||||
logs
|
||||
} else {
|
||||
getCommitLog(i, logs :+ new CommitInfo(revCommit))
|
||||
}
|
||||
}
|
||||
case false => logs
|
||||
}
|
||||
|
||||
val revWalk = new RevWalk(git.getRepository)
|
||||
revWalk.markStart(revWalk.parseCommit(git.getRepository.resolve(to)))
|
||||
|
||||
val commits = getCommitLog(revWalk.iterator, Nil)
|
||||
revWalk.release
|
||||
|
||||
commits.reverse
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the latest RevCommit of the specified path.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user