mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-07 14:05:52 +01:00
(refs #33)Match committer by mail address.
This commit is contained in:
@@ -43,8 +43,10 @@ object JGitUtil {
|
|||||||
* @param message the last commit message
|
* @param message the last commit message
|
||||||
* @param commitId the last commit id
|
* @param commitId the last commit id
|
||||||
* @param committer the last committer name
|
* @param committer the last committer name
|
||||||
|
* @param mailAddress the committer's mail address
|
||||||
*/
|
*/
|
||||||
case class FileInfo(id: ObjectId, isDirectory: Boolean, name: String, time: Date, message: String, commitId: String, committer: String)
|
case class FileInfo(id: ObjectId, isDirectory: Boolean, name: String, time: Date, message: String, commitId: String,
|
||||||
|
committer: String, mailAddress: String)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The commit data.
|
* The commit data.
|
||||||
@@ -52,14 +54,18 @@ object JGitUtil {
|
|||||||
* @param id the commit id
|
* @param id the commit id
|
||||||
* @param time the commit time
|
* @param time the commit time
|
||||||
* @param committer the committer name
|
* @param committer the committer name
|
||||||
|
* @param mailAddress the committer's mail address
|
||||||
* @param shortMessage the short message
|
* @param shortMessage the short message
|
||||||
* @param fullMessage the full message
|
* @param fullMessage the full message
|
||||||
* @param parents the list of parent commit id
|
* @param parents the list of parent commit id
|
||||||
*/
|
*/
|
||||||
case class CommitInfo(id: String, time: Date, committer: String, shortMessage: String, fullMessage: String, parents: List[String]){
|
case class CommitInfo(id: String, time: Date, committer: String, mailAddress: String,
|
||||||
|
shortMessage: String, fullMessage: String, parents: List[String]){
|
||||||
|
|
||||||
def this(rev: org.eclipse.jgit.revwalk.RevCommit) = this(
|
def this(rev: org.eclipse.jgit.revwalk.RevCommit) = this(
|
||||||
rev.getName, rev.getCommitterIdent.getWhen, rev.getCommitterIdent.getName, rev.getShortMessage, rev.getFullMessage,
|
rev.getName, rev.getCommitterIdent.getWhen,
|
||||||
|
rev.getCommitterIdent.getName, rev.getCommitterIdent.getEmailAddress,
|
||||||
|
rev.getShortMessage, rev.getFullMessage,
|
||||||
rev.getParents().map(_.name).toList)
|
rev.getParents().map(_.name).toList)
|
||||||
|
|
||||||
val summary = {
|
val summary = {
|
||||||
@@ -233,7 +239,8 @@ object JGitUtil {
|
|||||||
commits(path).getCommitterIdent.getWhen,
|
commits(path).getCommitterIdent.getWhen,
|
||||||
commits(path).getShortMessage,
|
commits(path).getShortMessage,
|
||||||
commits(path).getName,
|
commits(path).getName,
|
||||||
commits(path).getCommitterIdent.getName)
|
commits(path).getCommitterIdent.getName,
|
||||||
|
commits(path).getCommitterIdent.getEmailAddress)
|
||||||
}.sortWith { (file1, file2) =>
|
}.sortWith { (file1, file2) =>
|
||||||
(file1.isDirectory, file2.isDirectory) match {
|
(file1.isDirectory, file2.isDirectory) match {
|
||||||
case (true , false) => true
|
case (true , false) => true
|
||||||
|
|||||||
@@ -79,14 +79,27 @@ object helpers {
|
|||||||
.replaceAll("(^|\\W)([a-f0-9]{40})(\\W|$)", s"""$$1<a href="${context.path}/${repository.owner}/${repository.name}/commit/$$2">$$2</a>$$3"""))
|
.replaceAll("(^|\\W)([a-f0-9]{40})(\\W|$)", s"""$$1<a href="${context.path}/${repository.owner}/${repository.name}/commit/$$2">$$2</a>$$3"""))
|
||||||
|
|
||||||
|
|
||||||
|
def user(userName: String, mailAddress: String, styleClass: String = "")(implicit context: app.Context): Html = {
|
||||||
|
val account = context.cache(s"account.${mailAddress}"){
|
||||||
|
new AccountService {}.getAccountByMailAddress(mailAddress)
|
||||||
|
}
|
||||||
|
account.map { account =>
|
||||||
|
Html(s"""<a href="${url(account.userName)}" class="${styleClass}">${userName}</a>""")
|
||||||
|
} getOrElse Html(userName)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns <img> which displays the avatar icon.
|
* Returns <img> which displays the avatar icon.
|
||||||
* Looks up Gravatar if avatar icon has not been configured in user settings.
|
* Looks up Gravatar if avatar icon has not been configured in user settings.
|
||||||
*/
|
*/
|
||||||
def avatar(userName: String, size: Int, tooltip: Boolean = false)(implicit context: app.Context): Html = {
|
def avatar(userName: String, size: Int, tooltip: Boolean = false)(implicit context: app.Context): Html = {
|
||||||
val account = context.cache(s"account.${userName}"){
|
val account = context.cache(s"account.${userName}"){
|
||||||
|
if(userName.contains("@")){
|
||||||
|
new AccountService {}.getAccountByMailAddress(userName)
|
||||||
|
} else {
|
||||||
new AccountService {}.getAccountByUserName(userName)
|
new AccountService {}.getAccountByUserName(userName)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
val src = account.collect { case account if(account.image.isEmpty) =>
|
val src = account.collect { case account if(account.image.isEmpty) =>
|
||||||
s"""http://www.gravatar.com/avatar/${StringUtil.md5(account.mailAddress)}?s=${size}"""
|
s"""http://www.gravatar.com/avatar/${StringUtil.md5(account.mailAddress)}?s=${size}"""
|
||||||
} getOrElse {
|
} getOrElse {
|
||||||
|
|||||||
@@ -23,7 +23,8 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<th style="font-weight: normal;">
|
<th style="font-weight: normal;">
|
||||||
<div class="pull-left">
|
<div class="pull-left">
|
||||||
<a href="@url(latestCommit.committer)" class="username strong">@latestCommit.committer</a>
|
@avatar(latestCommit.mailAddress, 20)
|
||||||
|
@user(latestCommit.committer, latestCommit.mailAddress, "username strong")
|
||||||
<span class="muted">@datetime(latestCommit.time)</span>
|
<span class="muted">@datetime(latestCommit.time)</span>
|
||||||
<a href="@url(repository)/commit/@latestCommit.id" class="commit-message">@link(latestCommit.summary, repository)</a>
|
<a href="@url(repository)/commit/@latestCommit.id" class="commit-message">@link(latestCommit.summary, repository)</a>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -43,8 +43,8 @@
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
@avatar(commit.committer, 20)
|
@avatar(commit.mailAddress, 20)
|
||||||
<a href="@url(commit.committer)" class="username strong">@commit.committer</a>
|
@user(commit.committer, commit.mailAddress, "username strong")
|
||||||
<span class="muted">@datetime(commit.time)</span>
|
<span class="muted">@datetime(commit.time)</span>
|
||||||
<div class="pull-right monospace small" style="text-align: right;">
|
<div class="pull-right monospace small" style="text-align: right;">
|
||||||
<div>
|
<div>
|
||||||
|
|||||||
@@ -38,7 +38,7 @@
|
|||||||
<a href="@url(repository)/tree/@commit.id" class="small">Browse code</a>
|
<a href="@url(repository)/tree/@commit.id" class="small">Browse code</a>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<div class="commit-avatar-image">@avatar(commit.committer, 40)</div>
|
<div class="commit-avatar-image">@avatar(commit.mailAddress, 40)</div>
|
||||||
<a href="@url(repository)/commit/@commit.id" class="commit-message" style="font-weight: bold;">@link(commit.summary, repository)</a>
|
<a href="@url(repository)/commit/@commit.id" class="commit-message" style="font-weight: bold;">@link(commit.summary, repository)</a>
|
||||||
@if(commit.description.isDefined){
|
@if(commit.description.isDefined){
|
||||||
<a href="javascript:void(0)" onclick="$('#description-@commit.id').toggle();" class="omit">...</a>
|
<a href="javascript:void(0)" onclick="$('#description-@commit.id').toggle();" class="omit">...</a>
|
||||||
@@ -48,7 +48,7 @@
|
|||||||
<pre id="description-@commit.id" style="display: none;" class="commit-description">@link(commit.description.get, repository)</pre>
|
<pre id="description-@commit.id" style="display: none;" class="commit-description">@link(commit.description.get, repository)</pre>
|
||||||
}
|
}
|
||||||
<div class="small">
|
<div class="small">
|
||||||
<a href="@url(commit.committer)" class="username">@commit.committer</a>
|
@user(commit.committer, commit.mailAddress, "username")
|
||||||
<span class="muted">@datetime(commit.time)</span>
|
<span class="muted">@datetime(commit.time)</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -36,8 +36,8 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td colspan="4" class="latest-commit">
|
<td colspan="4" class="latest-commit">
|
||||||
<div>
|
<div>
|
||||||
@avatar(latestCommit.committer, 20)
|
@avatar(latestCommit.mailAddress, 20)
|
||||||
<a href="@url(latestCommit.committer)" class="username strong">@latestCommit.committer</a>
|
@user(latestCommit.committer, latestCommit.mailAddress, "username strong")
|
||||||
<span class="muted">@datetime(latestCommit.time)</span>
|
<span class="muted">@datetime(latestCommit.time)</span>
|
||||||
<div class="pull-right align-right monospace">
|
<div class="pull-right align-right monospace">
|
||||||
<a href="@url(repository)/commit/@latestCommit.id" class="commit-id"><span class="muted">latest commit</span> @latestCommit.id.substring(0, 10)</a>
|
<a href="@url(repository)/commit/@latestCommit.id" class="commit-id"><span class="muted">latest commit</span> @latestCommit.id.substring(0, 10)</a>
|
||||||
@@ -70,7 +70,10 @@
|
|||||||
}
|
}
|
||||||
</td>
|
</td>
|
||||||
<td>@datetime(file.time)</td>
|
<td>@datetime(file.time)</td>
|
||||||
<td><a href="@url(repository)/commit/@file.commitId" class="commit-message">@link(file.message, repository)</a> [<a href="@url(file.committer)">@file.committer</a>]</td>
|
<td>
|
||||||
|
<a href="@url(repository)/commit/@file.commitId" class="commit-message">@link(file.message, repository)</a>
|
||||||
|
[@user(file.committer, file.mailAddress)]
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
}
|
}
|
||||||
</table>
|
</table>
|
||||||
|
|||||||
Reference in New Issue
Block a user