mirror of
				https://github.com/gitbucket/gitbucket.git
				synced 2025-10-31 02:25:59 +01:00 
			
		
		
		
	Fix commit log presentation.
This commit is contained in:
		| @@ -75,7 +75,7 @@ class CommitLogHook(owner: String, repository: String) extends PostReceiveHook { | |||||||
|       commands.asScala.foreach { command => |       commands.asScala.foreach { command => | ||||||
|         JGitUtil.getCommitLog(git, command.getOldId.name, command.getNewId.name).foreach { commit => |         JGitUtil.getCommitLog(git, command.getOldId.name, command.getNewId.name).foreach { commit => | ||||||
|           // TODO extract issue id and add comment to issue |           // TODO extract issue id and add comment to issue | ||||||
|           logger.debug(commit.id + ":" + commit.message) |           logger.debug(commit.id + ":" + commit.shortMessage) | ||||||
|         } |         } | ||||||
|       } |       } | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -50,11 +50,22 @@ 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 commiter name |    * @param committer  the commiter name | ||||||
|    * @param message the commit message |    * @param shortMessage the short message | ||||||
|  |    * @param fullMessage the full message | ||||||
|    */ |    */ | ||||||
|   case class CommitInfo(id: String, time: Date, committer: String, message: String){ |   case class CommitInfo(id: String, time: Date, committer: String, shortMessage: String, fullMessage: String){ | ||||||
|     def this(rev: org.eclipse.jgit.revwalk.RevCommit) = |     def this(rev: org.eclipse.jgit.revwalk.RevCommit) = | ||||||
|       this(rev.getName, rev.getCommitterIdent.getWhen, rev.getCommitterIdent.getName, rev.getFullMessage) |       this(rev.getName, rev.getCommitterIdent.getWhen, rev.getCommitterIdent.getName, rev.getShortMessage, rev.getFullMessage) | ||||||
|  |  | ||||||
|  |     val description = { | ||||||
|  |       val i = fullMessage.trim.indexOf("\n") | ||||||
|  |       if(i >= 0){ | ||||||
|  |         Some(fullMessage.trim.substring(i).trim) | ||||||
|  |       } else { | ||||||
|  |         None | ||||||
|  |       } | ||||||
|  |     } | ||||||
|  |  | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   case class DiffInfo(changeType: ChangeType, oldPath: String, newPath: String, oldContent: Option[String], newContent: Option[String]) |   case class DiffInfo(changeType: ChangeType, oldPath: String, newPath: String, oldContent: Option[String], newContent: Option[String]) | ||||||
|   | |||||||
| @@ -14,11 +14,28 @@ object helpers { | |||||||
|    * Format java.util.Date to "yyyy/MM/dd". |    * Format java.util.Date to "yyyy/MM/dd". | ||||||
|    */ |    */ | ||||||
|   def date(date: Date): String = new SimpleDateFormat("yyyy/MM/dd").format(date) |   def date(date: Date): String = new SimpleDateFormat("yyyy/MM/dd").format(date) | ||||||
|    |  | ||||||
|  |   def format(value: String): Html = | ||||||
|  |     Html(value.replaceAll(" ", " ").replaceAll("\t", "    ").replaceAll("\n", "<br>")) | ||||||
|  |  | ||||||
|   // TODO escape html tags using HtmlEscapeUtils (Commons Lang) |   // TODO escape html tags using HtmlEscapeUtils (Commons Lang) | ||||||
|   def format(value: String): Html = Html( |   def formatCommitLog(message: String): Html = { | ||||||
|     value.replaceAll(" ", " ").replaceAll("\t", "    ").replaceAll("\n", "<br>")) |     val i = message.trim.indexOf("\n") | ||||||
|      |     val (firstLine, description) = if(i >= 0){ | ||||||
|  |       (message.trim.substring(0, i).trim, Some(message.trim.substring(i).trim)) | ||||||
|  |     } else { | ||||||
|  |       (message.trim, None) | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     val sb = new StringBuilder() | ||||||
|  |     sb.append("<div class=\"summary\">").append(format(firstLine).text).append("</div>") | ||||||
|  |     if(description.isDefined){ | ||||||
|  |       sb.append("<div class=\"description\">").append(format(description.get).text).append("</div>") | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     Html(sb.toString) | ||||||
|  |   } | ||||||
|  |  | ||||||
|   /** |   /** | ||||||
|    * Converts Markdown of Wiki pages to HTML. |    * Converts Markdown of Wiki pages to HTML. | ||||||
|    */ |    */ | ||||||
| @@ -27,15 +44,15 @@ object helpers { | |||||||
|     Html(Markdown.toHtml(value, repository, enableWikiLink, enableCommitLink, enableIssueLink)) |     Html(Markdown.toHtml(value, repository, enableWikiLink, enableCommitLink, enableIssueLink)) | ||||||
|   } |   } | ||||||
|    |    | ||||||
|   /** | //  /** | ||||||
|    * Cut the given string by specified length. | //   * Cut the given string by specified length. | ||||||
|    */ | //   */ | ||||||
|   def cut(message: String, length: Int): String = { | //  def cut(message: String, length: Int): String = { | ||||||
|     if(message.length > length){ | //    if(message.length > length){ | ||||||
|       message.substring(0, length) + "..." | //      message.substring(0, length) + "..." | ||||||
|     } else { | //    } else { | ||||||
|       message | //      message | ||||||
|     } | //    } | ||||||
|   } | //  } | ||||||
|    |    | ||||||
| } | } | ||||||
| @@ -21,7 +21,7 @@ | |||||||
|         <div class="pull-left"> |         <div class="pull-left"> | ||||||
|           <a href="@path/@latestCommit.committer">@latestCommit.committer</a> |           <a href="@path/@latestCommit.committer">@latestCommit.committer</a> | ||||||
|           <span class="description">@helpers.datetime(latestCommit.time)</span> |           <span class="description">@helpers.datetime(latestCommit.time)</span> | ||||||
|           <a href="@path/@repository.owner/@repository.name/commit/@latestCommit.id" class="commit-message">@helpers.cut(latestCommit.message, 100)</a> |           <a href="@path/@repository.owner/@repository.name/commit/@latestCommit.id" class="commit-message">@latestCommit.shortMessage</a> | ||||||
|         </div> |         </div> | ||||||
|         <div class="btn-group pull-right"> |         <div class="btn-group pull-right"> | ||||||
|           <a class="btn btn-mini" href="?raw=true">Raw</a> |           <a class="btn btn-mini" href="?raw=true">Raw</a> | ||||||
|   | |||||||
| @@ -2,13 +2,13 @@ | |||||||
| @import context._ | @import context._ | ||||||
| @import view.helpers | @import view.helpers | ||||||
| @import org.eclipse.jgit.diff.DiffEntry.ChangeType | @import org.eclipse.jgit.diff.DiffEntry.ChangeType | ||||||
| @html.main(helpers.cut(commit.message, 20)){ | @html.main(commit.shortMessage){ | ||||||
|   @html.header("code", repository) |   @html.header("code", repository) | ||||||
|   @navtab(branch, repository, "commits") |   @navtab(branch, repository, "commits") | ||||||
|   <table class="table table-bordered"> |   <table class="table table-bordered"> | ||||||
|     <tr> |     <tr> | ||||||
|       <th> |       <th> | ||||||
|         <div>@helpers.format(commit.message)</div> |         <div class="commit-log">@helpers.formatCommitLog(commit.fullMessage)</div> | ||||||
|         <div class="small" style="font-weight: normal;"><span class="description">@branch</span></div> |         <div class="small" style="font-weight: normal;"><span class="description">@branch</span></div> | ||||||
|       </th> |       </th> | ||||||
|     </tr> |     </tr> | ||||||
|   | |||||||
| @@ -30,7 +30,16 @@ | |||||||
|       <tr> |       <tr> | ||||||
|         <td> |         <td> | ||||||
|           <div class="pull-left"> |           <div class="pull-left"> | ||||||
|             <a href="@path/@repository.owner/@repository.name/commit/@commit.id"><strong>@helpers.cut(commit.message, 100)</strong></a><br> |             <a href="@path/@repository.owner/@repository.name/commit/@commit.id"><strong>@commit.shortMessage</strong></a> | ||||||
|  |             @if(commit.description.isDefined){ | ||||||
|  |               <a href="javascript:void(0)" onclick="$('#description-@commit.id').toggle();">...</a> | ||||||
|  |             } | ||||||
|  |             <br> | ||||||
|  |             @if(commit.description.isDefined){ | ||||||
|  |               <div class="small" id="description-@commit.id" style="display: none;"> | ||||||
|  |                 @helpers.format(commit.description.get) | ||||||
|  |               </div> | ||||||
|  |             } | ||||||
|             <div class="small"> |             <div class="small"> | ||||||
|               <a href="@path/@commit.committer">@commit.committer</a> |               <a href="@path/@commit.committer">@commit.committer</a> | ||||||
|               <span class="description">@helpers.datetime(commit.time)</span> |               <span class="description">@helpers.datetime(commit.time)</span> | ||||||
|   | |||||||
| @@ -16,7 +16,7 @@ | |||||||
|         <th colspan="4" style="font-weight: normal;"> |         <th colspan="4" style="font-weight: normal;"> | ||||||
|           <div> |           <div> | ||||||
|             <strong><a href="@path/@repository.owner/@repository.name/@latestCommit.committer">@latestCommit.committer</a></strong>  |             <strong><a href="@path/@repository.owner/@repository.name/@latestCommit.committer">@latestCommit.committer</a></strong>  | ||||||
|             <a href="@path/@repository.owner/@repository.name/commit/@latestCommit.id" class="commit-message">@helpers.cut(latestCommit.message, 100)</a> |             <a href="@path/@repository.owner/@repository.name/commit/@latestCommit.id" class="commit-message">@latestCommit.shortMessage</a> | ||||||
|             <div class="pull-right align-right"> |             <div class="pull-right align-right"> | ||||||
|               @helpers.datetime(latestCommit.time) |               @helpers.datetime(latestCommit.time) | ||||||
|               <a href="@path/@repository.owner/@repository.name/commit/@latestCommit.id">@latestCommit.id.substring(0, 10)</a> |               <a href="@path/@repository.owner/@repository.name/commit/@latestCommit.id">@latestCommit.id.substring(0, 10)</a> | ||||||
| @@ -49,7 +49,7 @@ | |||||||
|         } |         } | ||||||
|         </td> |         </td> | ||||||
|         <td>@helpers.datetime(file.time)</td> |         <td>@helpers.datetime(file.time)</td> | ||||||
|         <td><a href="@path/@repository.owner/@repository.name/commit/@file.commitId" class="commit-message">@helpers.cut(file.message, 60)</a> [<a href="@path/@file.committer">@file.committer</a>]</td> |         <td><a href="@path/@repository.owner/@repository.name/commit/@file.commitId" class="commit-message">@file.message</a> [<a href="@path/@file.committer">@file.committer</a>]</td> | ||||||
|       </tr> |       </tr> | ||||||
|       } |       } | ||||||
|     </table> |     </table> | ||||||
|   | |||||||
| @@ -36,7 +36,7 @@ | |||||||
|         <td><a href="@path/@commit.committer">@commit.committer</a></td> |         <td><a href="@path/@commit.committer">@commit.committer</a></td> | ||||||
|         <td width="80%"> |         <td width="80%"> | ||||||
|           <span class="description">@helpers.datetime(commit.time):</span> |           <span class="description">@helpers.datetime(commit.time):</span> | ||||||
|           @commit.message |           @commit.shortMessage | ||||||
|         </td> |         </td> | ||||||
|       </tr> |       </tr> | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -97,6 +97,10 @@ div.block { | |||||||
|   border-bottom: 1px solid silver; |   border-bottom: 1px solid silver; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | div.commit-log div.description { | ||||||
|  |   font-weight: normal; | ||||||
|  | } | ||||||
|  |  | ||||||
| h1.wiki-title { | h1.wiki-title { | ||||||
|   margin-top: 0px; |   margin-top: 0px; | ||||||
| } | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user