diff --git a/src/main/scala/app/PullRequestsController.scala b/src/main/scala/app/PullRequestsController.scala index e7680e9..8fd4672 100644 --- a/src/main/scala/app/PullRequestsController.scala +++ b/src/main/scala/app/PullRequestsController.scala @@ -443,7 +443,7 @@ 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) diff --git a/src/main/scala/app/RepositoryViewerController.scala b/src/main/scala/app/RepositoryViewerController.scala index ab2cf05..0fea61f 100644 --- a/src/main/scala/app/RepositoryViewerController.scala +++ b/src/main/scala/app/RepositoryViewerController.scala @@ -106,7 +106,7 @@ 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 } diff --git a/src/main/scala/service/WebHookService.scala b/src/main/scala/service/WebHookService.scala index 9f3f11e..232eac1 100644 --- a/src/main/scala/service/WebHookService.scala +++ b/src/main/scala/service/WebHookService.scala @@ -90,15 +90,15 @@ 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 ) ) }, diff --git a/src/main/scala/service/WikiService.scala b/src/main/scala/service/WikiService.scala index f634e34..ac9dbd6 100644 --- a/src/main/scala/service/WikiService.scala +++ b/src/main/scala/service/WikiService.scala @@ -64,7 +64,7 @@ if(!JGitUtil.isEmpty(git)){ JGitUtil.getFileList(git, "master", ".").find(_.name == pageName + ".md").map { file => WikiPageInfo(file.name, StringUtil.convertFromByteArray(git.getRepository.open(file.id).getBytes), - file.committer, file.time, file.commitId) + file.author, file.time, file.commitId) } } else None } diff --git a/src/main/scala/servlet/GitRepositoryServlet.scala b/src/main/scala/servlet/GitRepositoryServlet.scala index bf99ba0..012c6ea 100644 --- a/src/main/scala/servlet/GitRepositoryServlet.scala +++ b/src/main/scala/servlet/GitRepositoryServlet.scala @@ -205,7 +205,7 @@ 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") } } diff --git a/src/main/scala/util/JGitUtil.scala b/src/main/scala/util/JGitUtil.scala index f4ced75..ae1612c 100644 --- a/src/main/scala/util/JGitUtil.scala +++ b/src/main/scala/util/JGitUtil.scala @@ -47,38 +47,45 @@ * @param id the object id * @param isDirectory whether is it directory * @param name the file (or directory) name - * @param time the last modified time * @param message the last commit message * @param commitId the last commit id - * @param committer the last committer name + * @param time the last modified time + * @param author the last committer name * @param mailAddress the committer's mail address * @param linkUrl the url of submodule */ - case class FileInfo(id: ObjectId, isDirectory: Boolean, name: String, time: Date, message: String, commitId: String, - committer: String, mailAddress: String, linkUrl: Option[String]) + case class FileInfo(id: ObjectId, isDirectory: Boolean, name: String, message: String, commitId: String, + time: Date, author: String, mailAddress: String, linkUrl: Option[String]) /** * 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 @@ Some(fullMessage.trim.substring(i).trim) } else None } + + def isDifferentFromAuthor: Boolean = authorName != committerName || authorEmailAddress != committerEmailAddress } case class DiffInfo(changeType: ChangeType, oldPath: String, newPath: String, oldContent: Option[String], newContent: Option[String]) @@ -231,11 +240,11 @@ objectId, fileMode == FileMode.TREE || fileMode == FileMode.GITLINK, name, - commit.getCommitterIdent.getWhen, getSummaryMessage(commit.getFullMessage, commit.getShortMessage), commit.getName, - commit.getCommitterIdent.getName, - commit.getCommitterIdent.getEmailAddress, + commit.getAuthorIdent.getWhen, + commit.getAuthorIdent.getName, + commit.getAuthorIdent.getEmailAddress, linkUrl) } }.sortWith { (file1, file2) => diff --git a/src/main/scala/view/helpers.scala b/src/main/scala/view/helpers.scala index ddf4a0a..e83606a 100644 --- a/src/main/scala/view/helpers.scala +++ b/src/main/scala/view/helpers.scala @@ -74,7 +74,7 @@ * 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. diff --git a/src/main/twirl/pulls/commits.scala.html b/src/main/twirl/pulls/commits.scala.html index 68636d5..fa18056 100644 --- a/src/main/twirl/pulls/commits.scala.html +++ b/src/main/twirl/pulls/commits.scala.html @@ -6,13 +6,13 @@ @commits.map { day => - + @day.map { commit =>
@date(day.head.time)@date(day.head.commitTime)
@avatar(commit, 20) - @user(commit.committer, commit.mailAddress, "username") + @user(commit.authorName, commit.authorEmailAddress, "username") @commit.shortMessage diff --git a/src/main/twirl/repo/blob.scala.html b/src/main/twirl/repo/blob.scala.html index df13f90..52e2bb0 100644 --- a/src/main/twirl/repo/blob.scala.html +++ b/src/main/twirl/repo/blob.scala.html @@ -33,8 +33,8 @@
@avatar(latestCommit, 20) - @user(latestCommit.committer, latestCommit.mailAddress, "username strong") - @datetime(latestCommit.time) + @user(latestCommit.authorName, latestCommit.authorEmailAddress, "username strong") + @datetime(latestCommit.commitTime) @link(latestCommit.summary, repository)
diff --git a/src/main/twirl/repo/commit.scala.html b/src/main/twirl/repo/commit.scala.html index 61a2ce4..a022236 100644 --- a/src/main/twirl/repo/commit.scala.html +++ b/src/main/twirl/repo/commit.scala.html @@ -42,9 +42,6 @@
- @avatar(commit, 20) - @user(commit.committer, commit.mailAddress, "username strong") - @datetime(commit.time)
@if(commit.parents.size == 0){ @@ -66,6 +63,21 @@
}
+ +
+
+ @avatar(commit, 20) + @user(commit.authorName, commit.authorEmailAddress, "username strong") + authored on @datetime(commit.authorTime) +
+ @if(commit.isDifferentFromAuthor) { +
+ + @user(commit.committerName, commit.committerEmailAddress, "username strong") + committed on @datetime(commit.commitTime) +
+ } +
diff --git a/src/main/twirl/repo/commits.scala.html b/src/main/twirl/repo/commits.scala.html index 8fc49bf..be2b02f 100644 --- a/src/main/twirl/repo/commits.scala.html +++ b/src/main/twirl/repo/commits.scala.html @@ -36,7 +36,7 @@ @commits.map { day => - + @day.map { commit => @@ -57,8 +57,13 @@ }
- @user(commit.committer, commit.mailAddress, "username") - @datetime(commit.time) + @user(commit.authorName, commit.authorEmailAddress, "username") + authored @datetime(commit.authorTime) + @if(commit.isDifferentFromAuthor) { + + @user(commit.committerName, commit.committerEmailAddress, "username") + committed @datetime(commit.authorTime) + }
diff --git a/src/main/twirl/repo/files.scala.html b/src/main/twirl/repo/files.scala.html index 3e6d999..d0c074f 100644 --- a/src/main/twirl/repo/files.scala.html +++ b/src/main/twirl/repo/files.scala.html @@ -40,12 +40,23 @@ @@ -83,7 +94,7 @@ diff --git a/src/main/twirl/wiki/history.scala.html b/src/main/twirl/wiki/history.scala.html index 198f0b1..bd2ba49 100644 --- a/src/main/twirl/wiki/history.scala.html +++ b/src/main/twirl/wiki/history.scala.html @@ -34,9 +34,9 @@ @commits.map { commit => - + } diff --git a/src/main/webapp/assets/common/css/gitbucket.css b/src/main/webapp/assets/common/css/gitbucket.css index 934080d..e4a2988 100644 --- a/src/main/webapp/assets/common/css/gitbucket.css +++ b/src/main/webapp/assets/common/css/gitbucket.css @@ -825,6 +825,15 @@ } /****************************************************************************/ +/* Commit */ +/****************************************************************************/ +div.author-info div.committer { + display: block; + margin-left: 25px; + font-size: 12px; +} + +/****************************************************************************/ /* Diff */ /****************************************************************************/ table.inlinediff {
@date(day.head.time)@date(day.head.commitTime)
- @avatar(latestCommit, 20) - @user(latestCommit.committer, latestCommit.mailAddress, "username strong") - @datetime(latestCommit.time) +
+
+ @avatar(latestCommit, 20) + @user(latestCommit.authorName, latestCommit.authorEmailAddress, "username strong") + authored on @datetime(latestCommit.authorTime) +
+ @if(latestCommit.isDifferentFromAuthor) { +
+ + @user(latestCommit.committerName, latestCommit.committerEmailAddress, "username strong") + committed on @datetime(latestCommit.commitTime) +
+ } +
@link(file.message, repository) - [@user(file.committer, file.mailAddress)] + [@user(file.author, file.mailAddress)] @datetime(file.time)
@avatar(commit, 20) @user(commit.committer, commit.mailAddress)@avatar(commit, 20) @user(commit.authorName, commit.authorEmailAddress) - @datetime(commit.time): @commit.shortMessage + @datetime(commit.authorTime): @commit.shortMessage