mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-09 06:55:54 +01:00
(refs #437)Show author instead of committer
* Explicit classify committer and author * Use author to render avatar image html * Support commit view
This commit is contained in:
@@ -443,7 +443,7 @@ trait PullRequestsControllerBase extends ControllerBase {
|
||||
val commits = newGit.log.addRange(oldId, newId).call.iterator.asScala.map { revCommit =>
|
||||
new CommitInfo(revCommit)
|
||||
}.toList.splitWith { (commit1, commit2) =>
|
||||
view.helpers.date(commit1.time) == view.helpers.date(commit2.time)
|
||||
view.helpers.date(commit1.commitTime) == view.helpers.date(commit2.commitTime)
|
||||
}
|
||||
|
||||
val diffs = JGitUtil.getDiffs(newGit, oldId.getName, newId.getName, true)
|
||||
|
||||
@@ -106,7 +106,7 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
||||
case Right((logs, hasNext)) =>
|
||||
repo.html.commits(if(path.isEmpty) Nil else path.split("/").toList, branchName, repository,
|
||||
logs.splitWith{ (commit1, commit2) =>
|
||||
view.helpers.date(commit1.time) == view.helpers.date(commit2.time)
|
||||
view.helpers.date(commit1.commitTime) == view.helpers.date(commit2.commitTime)
|
||||
}, page, hasNext)
|
||||
case Left(_) => NotFound
|
||||
}
|
||||
|
||||
@@ -89,15 +89,15 @@ object WebHookService {
|
||||
WebHookCommit(
|
||||
id = commit.id,
|
||||
message = commit.fullMessage,
|
||||
timestamp = commit.time.toString,
|
||||
timestamp = commit.commitTime.toString,
|
||||
url = commitUrl,
|
||||
added = diffs._1.collect { case x if(x.changeType == DiffEntry.ChangeType.ADD) => x.newPath },
|
||||
removed = diffs._1.collect { case x if(x.changeType == DiffEntry.ChangeType.DELETE) => x.oldPath },
|
||||
modified = diffs._1.collect { case x if(x.changeType != DiffEntry.ChangeType.ADD &&
|
||||
x.changeType != DiffEntry.ChangeType.DELETE) => x.newPath },
|
||||
author = WebHookUser(
|
||||
name = commit.committer,
|
||||
email = commit.mailAddress
|
||||
name = commit.committerName,
|
||||
email = commit.committerEmailAddress
|
||||
)
|
||||
)
|
||||
},
|
||||
|
||||
@@ -205,7 +205,7 @@ class CommitLogHook(owner: String, repository: String, pusher: String, baseUrl:
|
||||
private def createIssueComment(commit: CommitInfo) = {
|
||||
StringUtil.extractIssueId(commit.fullMessage).foreach { issueId =>
|
||||
if(getIssue(owner, repository, issueId).isDefined){
|
||||
getAccountByMailAddress(commit.mailAddress).foreach { account =>
|
||||
getAccountByMailAddress(commit.committerEmailAddress).foreach { account =>
|
||||
createComment(owner, repository, account.userName, issueId.toInt, commit.fullMessage + " " + commit.id, "commit")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,24 +61,31 @@ object JGitUtil {
|
||||
* The commit data.
|
||||
*
|
||||
* @param id the commit id
|
||||
* @param time the commit time
|
||||
* @param committer the committer name
|
||||
* @param mailAddress the mail address of the committer
|
||||
* @param shortMessage the short message
|
||||
* @param fullMessage the full message
|
||||
* @param parents the list of parent commit id
|
||||
* @param authorTime the author time
|
||||
* @param authorName the author name
|
||||
* @param authorEmailAddress the mail address of the author
|
||||
* @param commitTime the commit time
|
||||
* @param committerName the committer name
|
||||
* @param committerEmailAddress the mail address of the committer
|
||||
*/
|
||||
case class CommitInfo(id: String, time: Date, committer: String, mailAddress: String,
|
||||
shortMessage: String, fullMessage: String, parents: List[String]){
|
||||
case class CommitInfo(id: String, shortMessage: String, fullMessage: String, parents: List[String],
|
||||
authorTime: Date, authorName: String, authorEmailAddress: String,
|
||||
commitTime: Date, committerName: String, committerEmailAddress: String){
|
||||
|
||||
def this(rev: org.eclipse.jgit.revwalk.RevCommit) = this(
|
||||
rev.getName,
|
||||
rev.getFullMessage,
|
||||
rev.getShortMessage,
|
||||
rev.getParents().map(_.name).toList,
|
||||
rev.getAuthorIdent.getWhen,
|
||||
rev.getAuthorIdent.getName,
|
||||
rev.getAuthorIdent.getEmailAddress,
|
||||
rev.getCommitterIdent.getWhen,
|
||||
rev.getCommitterIdent.getName,
|
||||
rev.getCommitterIdent.getEmailAddress,
|
||||
rev.getShortMessage,
|
||||
rev.getFullMessage,
|
||||
rev.getParents().map(_.name).toList)
|
||||
rev.getCommitterIdent.getEmailAddress)
|
||||
|
||||
val summary = getSummaryMessage(fullMessage, shortMessage)
|
||||
|
||||
@@ -87,6 +94,8 @@ object JGitUtil {
|
||||
Some(fullMessage.trim.substring(i).trim)
|
||||
} else None
|
||||
}
|
||||
|
||||
def isDiffrentCommitter: Boolean = authorName != committerName || authorEmailAddress != committerEmailAddress
|
||||
}
|
||||
|
||||
case class DiffInfo(changeType: ChangeType, oldPath: String, newPath: String, oldContent: Option[String], newContent: Option[String])
|
||||
|
||||
@@ -74,7 +74,7 @@ object helpers extends AvatarImageProvider with LinkConverter with RequestCache
|
||||
* This method looks up Gravatar if avatar icon has not been configured in user settings.
|
||||
*/
|
||||
def avatar(commit: util.JGitUtil.CommitInfo, size: Int)(implicit context: app.Context): Html =
|
||||
getAvatarImageHtml(commit.committer, size, commit.mailAddress)
|
||||
getAvatarImageHtml(commit.authorName, size, commit.authorEmailAddress)
|
||||
|
||||
/**
|
||||
* Converts commit id, issue id and username to the link.
|
||||
|
||||
Reference in New Issue
Block a user