mirror of
				https://github.com/gitbucket/gitbucket.git
				synced 2025-10-31 18:46:28 +01:00 
			
		
		
		
	Convert issue id and commit id in commit message to link.
This commit is contained in:
		| @@ -61,6 +61,9 @@ object JGitUtil { | |||||||
|         rev.getParents().map(_.name).toList) |         rev.getParents().map(_.name).toList) | ||||||
|  |  | ||||||
|     val description = { |     val description = { | ||||||
|  |       if(shortMessage == fullMessage){ | ||||||
|  |         None | ||||||
|  |       } else { | ||||||
|         val i = fullMessage.trim.indexOf("\n") |         val i = fullMessage.trim.indexOf("\n") | ||||||
|         if(i >= 0){ |         if(i >= 0){ | ||||||
|           Some(fullMessage.trim.substring(i).trim) |           Some(fullMessage.trim.substring(i).trim) | ||||||
| @@ -68,6 +71,7 @@ object JGitUtil { | |||||||
|           None |           None | ||||||
|         } |         } | ||||||
|       } |       } | ||||||
|  |     } | ||||||
|  |  | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -26,6 +26,18 @@ object helpers { | |||||||
|     Html(Markdown.toHtml(value, repository, enableWikiLink, enableCommitLink, enableIssueLink)) |     Html(Markdown.toHtml(value, repository, enableWikiLink, enableCommitLink, enableIssueLink)) | ||||||
|   } |   } | ||||||
|  |  | ||||||
|  |   /** | ||||||
|  |    * Converts issue id and commit id to link. | ||||||
|  |    */ | ||||||
|  |   def link(value: String, repository: service.RepositoryService.RepositoryInfo)(implicit context: app.Context): Html = | ||||||
|  |     Html(value | ||||||
|  |       // escape HTML tags | ||||||
|  |       .replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll("\"", """) | ||||||
|  |       // convert issue id to link | ||||||
|  |       .replaceAll("(^|\\W)#([0-9]+)(\\W|$)", "$1<a href=\"%s/%s/%s/issues/$2\">#$2</a>$3".format(context.path, repository.owner, repository.name)) | ||||||
|  |       // convert commit id to link | ||||||
|  |       .replaceAll("(^|\\W)([a-f0-9]{40})(\\W|$)", "$1<a href=\"%s/%s/%s/commit/$0\">$2</a>$3").format(context.path, repository.owner, repository.name)) | ||||||
|  |  | ||||||
| } | } | ||||||
|  |  | ||||||
| /** | /** | ||||||
|   | |||||||
| @@ -21,7 +21,7 @@ | |||||||
|         <div class="pull-left"> |         <div class="pull-left"> | ||||||
|           <a href="@path/@latestCommit.committer" class="username">@latestCommit.committer</a> |           <a href="@path/@latestCommit.committer" class="username">@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">@latestCommit.shortMessage</a> |           <a href="@path/@repository.owner/@repository.name/commit/@latestCommit.id" class="commit-message">@helpers.link(latestCommit.shortMessage, repository)</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> | ||||||
|   | |||||||
| @@ -12,9 +12,9 @@ | |||||||
|         <div class="pull-right align-right"> |         <div class="pull-right align-right"> | ||||||
|           <a href="@path/@repository.owner/@repository.name/tree/@commit.id" class="btn btn-small">Browse code</a> |           <a href="@path/@repository.owner/@repository.name/tree/@commit.id" class="btn btn-small">Browse code</a> | ||||||
|         </div> |         </div> | ||||||
|         <div class="commit-log">@commit.shortMessage</div> |         <div class="commit-log">@helpers.link(commit.shortMessage, repository)</div> | ||||||
|         @if(commit.description.isDefined){ |         @if(commit.description.isDefined){ | ||||||
|           <pre class="commit-description">@commit.description.get</pre> |           <pre class="commit-description">@helpers.link(commit.description.get, repository)</pre> | ||||||
|         } |         } | ||||||
|         <div class="small" style="font-weight: normal;"> |         <div class="small" style="font-weight: normal;"> | ||||||
|           @if(branches.nonEmpty){ |           @if(branches.nonEmpty){ | ||||||
|   | |||||||
| @@ -30,13 +30,13 @@ | |||||||
|       <tr> |       <tr> | ||||||
|         <td> |         <td> | ||||||
|           <div class="pull-left"> |           <div class="pull-left"> | ||||||
|             <a href="@path/@repository.owner/@repository.name/commit/@commit.id" class="commit-message" style="font-weight: bold;">@commit.shortMessage</a> |             <a href="@path/@repository.owner/@repository.name/commit/@commit.id" class="commit-message" style="font-weight: bold;">@helpers.link(commit.shortMessage, 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> | ||||||
|             } |             } | ||||||
|             <br> |             <br> | ||||||
|             @if(commit.description.isDefined){ |             @if(commit.description.isDefined){ | ||||||
|               <pre id="description-@commit.id" style="display: none;" class="commit-description">@commit.description.get</pre> |               <pre id="description-@commit.id" style="display: none;" class="commit-description">@helpers.link(commit.description.get, repository)</pre> | ||||||
|             } |             } | ||||||
|             <div class="small"> |             <div class="small"> | ||||||
|               <a href="@path/@commit.committer" class="committer">@commit.committer</a> |               <a href="@path/@commit.committer" class="committer">@commit.committer</a> | ||||||
|   | |||||||
| @@ -14,12 +14,12 @@ | |||||||
|     <table class="table table-file-list" style="border: 1px solid silver;"> |     <table class="table table-file-list" style="border: 1px solid silver;"> | ||||||
|       <tr> |       <tr> | ||||||
|         <th colspan="4" style="font-weight: normal;"> |         <th colspan="4" style="font-weight: normal;"> | ||||||
|           <a href="@path/@repository.owner/@repository.name/commit/@latestCommit.id" class="commit-message">@latestCommit.shortMessage</a> |           <a href="@path/@repository.owner/@repository.name/commit/@latestCommit.id" class="commit-message">@helpers.link(latestCommit.shortMessage, repository)</a> | ||||||
|           @if(latestCommit.description.isDefined){ |           @if(latestCommit.description.isDefined){ | ||||||
|             <a href="javascript:void(0)" onclick="$('#description-@latestCommit.id').toggle();" class="omit">...</a> |             <a href="javascript:void(0)" onclick="$('#description-@latestCommit.id').toggle();" class="omit">...</a> | ||||||
|           } |           } | ||||||
|           @if(latestCommit.description.isDefined){ |           @if(latestCommit.description.isDefined){ | ||||||
|             <pre id="description-@latestCommit.id" class="commit-description" style="display: none;">@latestCommit.description.get</pre> |             <pre id="description-@latestCommit.id" class="commit-description" style="display: none;">@helpers.link(latestCommit.description.get, repository)</pre> | ||||||
|           } |           } | ||||||
|         </th> |         </th> | ||||||
|       </tr> |       </tr> | ||||||
| @@ -59,7 +59,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">@file.message</a> [<a href="@path/@file.committer">@file.committer</a>]</td> |         <td><a href="@path/@repository.owner/@repository.name/commit/@file.commitId" class="commit-message">@helpers.link(file.message, repository)</a> [<a href="@path/@file.committer">@file.committer</a>]</td> | ||||||
|       </tr> |       </tr> | ||||||
|       } |       } | ||||||
|     </table> |     </table> | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user