Merge branch 'show-author'

This commit is contained in:
Tomofumi Tanaka
2014-07-31 22:48:15 +09:00
14 changed files with 86 additions and 40 deletions

View File

@@ -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)

View File

@@ -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
}

View File

@@ -90,15 +90,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
)
)
},

View File

@@ -64,7 +64,7 @@ trait WikiService {
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
}

View File

@@ -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")
}
}

View File

@@ -47,38 +47,45 @@ object JGitUtil {
* @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 @@ object JGitUtil {
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 @@ object JGitUtil {
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) =>

View File

@@ -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.

View File

@@ -6,13 +6,13 @@
<table class="table table-file-list" style="border: 1px solid silver;">
@commits.map { day =>
<tr>
<th colspan="3" class="box-header" style="font-weight: normal;">@date(day.head.time)</th>
<th colspan="3" class="box-header" style="font-weight: normal;">@date(day.head.commitTime)</th>
</tr>
@day.map { commit =>
<tr>
<td style="width: 20%;">
@avatar(commit, 20)
@user(commit.committer, commit.mailAddress, "username")
@user(commit.authorName, commit.authorEmailAddress, "username")
</td>
<td>@commit.shortMessage</td>
<td style="width: 10%; text-align: right;">

View File

@@ -33,8 +33,8 @@
<th style="font-weight: normal;">
<div class="pull-left">
@avatar(latestCommit, 20)
@user(latestCommit.committer, latestCommit.mailAddress, "username strong")
<span class="muted">@datetime(latestCommit.time)</span>
@user(latestCommit.authorName, latestCommit.authorEmailAddress, "username strong")
<span class="muted">@datetime(latestCommit.commitTime)</span>
<a href="@url(repository)/commit/@latestCommit.id" class="commit-message">@link(latestCommit.summary, repository)</a>
</div>
<div class="btn-group pull-right">

View File

@@ -42,9 +42,6 @@
</tr>
<tr>
<td>
@avatar(commit, 20)
@user(commit.committer, commit.mailAddress, "username strong")
<span class="muted">@datetime(commit.time)</span>
<div class="pull-right monospace small" style="text-align: right;">
<div>
@if(commit.parents.size == 0){
@@ -66,6 +63,21 @@
</div>
}
</div>
<div class="author-info">
<div class="author">
@avatar(commit, 20)
<span>@user(commit.authorName, commit.authorEmailAddress, "username strong")</span>
<span class="muted">authored on @datetime(commit.authorTime)</span>
</div>
@if(commit.isDifferentFromAuthor) {
<div class="committer">
<span class="icon-arrow-right"></span>
<span>@user(commit.committerName, commit.committerEmailAddress, "username strong")</span>
<span class="muted"> committed on @datetime(commit.commitTime)</span>
</div>
}
</div>
</td>
</tr>
</table>

View File

@@ -36,7 +36,7 @@
@commits.map { day =>
<table class="table table-bordered">
<tr>
<th>@date(day.head.time)</th>
<th>@date(day.head.commitTime)</th>
</tr>
@day.map { commit =>
<tr>
@@ -57,8 +57,13 @@
<pre id="description-@commit.id" style="display: none;" class="commit-description">@link(commit.description.get, repository)</pre>
}
<div class="small">
@user(commit.committer, commit.mailAddress, "username")
<span class="muted">@datetime(commit.time)</span>
@user(commit.authorName, commit.authorEmailAddress, "username")
<span class="muted">authored @datetime(commit.authorTime)</span>
@if(commit.isDifferentFromAuthor) {
<span class="icon-arrow-right" style="margin-top : -2px ;"></span>
@user(commit.committerName, commit.committerEmailAddress, "username")
<span class="muted">committed @datetime(commit.authorTime)</span>
}
</div>
</div>
</div>

View File

@@ -40,12 +40,23 @@
<tr>
<td colspan="4" class="latest-commit">
<div>
@avatar(latestCommit, 20)
@user(latestCommit.committer, latestCommit.mailAddress, "username strong")
<span class="muted">@datetime(latestCommit.time)</span>
<div class="pull-right align-right monospace" style="line-height: 18px;">
<a href="@url(repository)/commit/@latestCommit.id" class="commit-id"><span class="muted">latest commit</span> @latestCommit.id.substring(0, 10)</a>
</div>
<div class="author-info">
<div class="author">
@avatar(latestCommit, 20)
<span>@user(latestCommit.authorName, latestCommit.authorEmailAddress, "username strong")</span>
<span class="muted"> authored on @datetime(latestCommit.authorTime)</span>
</div>
@if(latestCommit.isDifferentFromAuthor) {
<div class="committer">
<span class="icon-arrow-right"></span>
<span>@user(latestCommit.committerName, latestCommit.committerEmailAddress, "username strong")</span>
<span class="muted"> committed on @datetime(latestCommit.commitTime)</span>
</div>
}
</div>
</div>
</td>
</tr>
@@ -83,7 +94,7 @@
</td>
<td class="mute">
<a href="@url(repository)/commit/@file.commitId" class="commit-message">@link(file.message, repository)</a>
[@user(file.committer, file.mailAddress)]
[@user(file.author, file.mailAddress)]
</td>
<td style="text-align: right;">@datetime(file.time)</td>
</tr>

View File

@@ -34,9 +34,9 @@
@commits.map { commit =>
<tr>
<td width="0%"><input type="checkbox" name="commitId" value="@commit.id"></td>
<td>@avatar(commit, 20)&nbsp;@user(commit.committer, commit.mailAddress)</td>
<td>@avatar(commit, 20)&nbsp;@user(commit.authorName, commit.authorEmailAddress)</td>
<td width="80%">
<span class="muted">@datetime(commit.time):</span>&nbsp;@commit.shortMessage
<span class="muted">@datetime(commit.authorTime):</span>&nbsp;@commit.shortMessage
</td>
</tr>
}

View File

@@ -824,6 +824,15 @@ a.absent {
color: #c00;
}
/****************************************************************************/
/* Commit */
/****************************************************************************/
div.author-info div.committer {
display: block;
margin-left: 25px;
font-size: 12px;
}
/****************************************************************************/
/* Diff */
/****************************************************************************/