From 9e19821256f7a43b719bffe8dbcfedef87345511 Mon Sep 17 00:00:00 2001 From: SIkebe Date: Tue, 10 Dec 2019 10:45:19 +0900 Subject: [PATCH] Change branch name text in PR into link (#2394) --- src/main/scala/gitbucket/core/view/helpers.scala | 13 +++++++++++++ src/main/twirl/gitbucket/core/pulls/menu.scala.html | 12 ++++++------ 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/main/scala/gitbucket/core/view/helpers.scala b/src/main/scala/gitbucket/core/view/helpers.scala index b364b1e4a..4cb6f2950 100644 --- a/src/main/scala/gitbucket/core/view/helpers.scala +++ b/src/main/scala/gitbucket/core/view/helpers.scala @@ -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. */ diff --git a/src/main/twirl/gitbucket/core/pulls/menu.scala.html b/src/main/twirl/gitbucket/core/pulls/menu.scala.html index 88271d964..ed4349549 100644 --- a/src/main/twirl/gitbucket/core/pulls/menu.scala.html +++ b/src/main/twirl/gitbucket/core/pulls/menu.scala.html @@ -47,8 +47,8 @@ @helpers.user(comment.commentedUserName, styleClass = "username strong") merged @commits.size @helpers.plural(commits.size, "commit") - into @pullreq.userName:@pullreq.branch - from @pullreq.requestUserName:@pullreq.requestBranch + into @pullreq.userName:@pullreq.branch + from @pullreq.requestUserName:@pullreq.requestBranch @gitbucket.core.helper.html.datetimeago(comment.registeredDate) }.getOrElse { @@ -56,8 +56,8 @@ @helpers.user(issue.openedUserName, styleClass = "username strong") wants to merge @commits.size @helpers.plural(commits.size, "commit") - into @pullreq.userName:@pullreq.branch - from @pullreq.requestUserName:@pullreq.requestBranch + into @pullreq.userName:@pullreq.branch + from @pullreq.requestUserName:@pullreq.requestBranch } } else { @@ -65,8 +65,8 @@ @helpers.user(issue.openedUserName, styleClass = "username strong") wants to merge @commits.size @helpers.plural(commits.size, "commit") - into @pullreq.userName:@pullreq.branch - from @pullreq.requestUserName:@pullreq.requestBranch + into @pullreq.userName:@pullreq.branch + from @pullreq.requestUserName:@pullreq.requestBranch }