Change branch name text in PR into link (#2394)

This commit is contained in:
SIkebe
2019-12-10 10:45:19 +09:00
committed by Naoki Takezoe
parent 455183a13e
commit 9e19821256
2 changed files with 19 additions and 6 deletions

View File

@@ -6,6 +6,7 @@ import java.util.{Date, Locale, TimeZone}
import com.nimbusds.jose.util.JSONObjectUtils
import gitbucket.core.controller.Context
import gitbucket.core.model.CommitState
import gitbucket.core.model.PullRequest
import gitbucket.core.plugin.{PluginRegistry, RenderRequest}
import gitbucket.core.service.RepositoryService.RepositoryInfo
import gitbucket.core.service.{RepositoryService, RequestCache}
@@ -273,6 +274,18 @@ object helpers extends AvatarImageProvider with LinkConverter with RequestCache
*/
def url(userName: String)(implicit context: Context): String = s"${context.path}/${encodeRefName(userName)}"
/**
* Generates the url to the pull request base branch.
*/
def basePRBranchUrl(pullreq: PullRequest)(implicit context: Context): String =
s"${context.path}/${encodeRefName(pullreq.userName)}/${encodeRefName(pullreq.repositoryName)}/tree/${encodeRefName(pullreq.branch)}"
/**
* Generates the url to the pull request branch.
*/
def requestPRBranchUrl(pullreq: PullRequest)(implicit context: Context): String =
s"${context.path}/${encodeRefName(pullreq.requestUserName)}/${encodeRefName(pullreq.repositoryName)}/tree/${encodeRefName(pullreq.requestBranch)}"
/**
* Returns the url to the root of assets.
*/

View File

@@ -47,8 +47,8 @@
<span class="muted">
@helpers.user(comment.commentedUserName, styleClass = "username strong")
merged @commits.size @helpers.plural(commits.size, "commit")
into <code>@pullreq.userName:@pullreq.branch</code>
from <code>@pullreq.requestUserName:@pullreq.requestBranch</code>
into <code><a href="@helpers.basePRBranchUrl(pullreq)">@pullreq.userName:@pullreq.branch</a></code>
from <code><a href="@helpers.requestPRBranchUrl(pullreq)">@pullreq.requestUserName:@pullreq.requestBranch</a></code>
@gitbucket.core.helper.html.datetimeago(comment.registeredDate)
</span>
}.getOrElse {
@@ -56,8 +56,8 @@
<span class="muted">
@helpers.user(issue.openedUserName, styleClass = "username strong")
wants to merge @commits.size @helpers.plural(commits.size, "commit")
into <code>@pullreq.userName:@pullreq.branch</code>
from <code>@pullreq.requestUserName:@pullreq.requestBranch</code>
into <code><a href="@helpers.basePRBranchUrl(pullreq)">@pullreq.userName:@pullreq.branch</a></code>
from <code><a href="@helpers.requestPRBranchUrl(pullreq)">@pullreq.requestUserName:@pullreq.requestBranch</a></code>
</span>
}
} else {
@@ -65,8 +65,8 @@
<span class="muted">
@helpers.user(issue.openedUserName, styleClass = "username strong")
wants to merge @commits.size @helpers.plural(commits.size, "commit")
into <code>@pullreq.userName:@pullreq.branch</code>
from <code>@pullreq.requestUserName:@pullreq.requestBranch</code>
into <code><a href="@helpers.basePRBranchUrl(pullreq)">@pullreq.userName:@pullreq.branch</a></code>
from <code><a href="@helpers.requestPRBranchUrl(pullreq)">@pullreq.requestUserName:@pullreq.requestBranch</a></code>
</span>
}
</div>