mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-10 12:15:43 +01:00
parent
7ab6c77b41
commit
4c82485424
3 changed files with 41 additions and 6 deletions
|
@ -13,6 +13,7 @@ import (
|
||||||
"code.gitea.io/gitea/modules/log"
|
"code.gitea.io/gitea/modules/log"
|
||||||
"code.gitea.io/gitea/modules/setting"
|
"code.gitea.io/gitea/modules/setting"
|
||||||
"code.gitea.io/gitea/modules/timeutil"
|
"code.gitea.io/gitea/modules/timeutil"
|
||||||
|
"code.gitea.io/gitea/modules/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
// PullRequestType defines pull request type
|
// PullRequestType defines pull request type
|
||||||
|
@ -638,3 +639,27 @@ func (pr *PullRequest) updateCommitDivergence(e Engine, ahead, behind int) error
|
||||||
func (pr *PullRequest) IsSameRepo() bool {
|
func (pr *PullRequest) IsSameRepo() bool {
|
||||||
return pr.BaseRepoID == pr.HeadRepoID
|
return pr.BaseRepoID == pr.HeadRepoID
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetBaseBranchHTMLURL returns the HTML URL of the base branch
|
||||||
|
func (pr *PullRequest) GetBaseBranchHTMLURL() string {
|
||||||
|
if err := pr.LoadBaseRepo(); err != nil {
|
||||||
|
log.Error("LoadBaseRepo: %v", err)
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
if pr.BaseRepo == nil {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
return pr.BaseRepo.HTMLURL() + "/src/branch/" + util.PathEscapeSegments(pr.BaseBranch)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetHeadBranchHTMLURL returns the HTML URL of the head branch
|
||||||
|
func (pr *PullRequest) GetHeadBranchHTMLURL() string {
|
||||||
|
if err := pr.LoadHeadRepo(); err != nil {
|
||||||
|
log.Error("LoadHeadRepo: %v", err)
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
if pr.HeadRepo == nil {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
return pr.HeadRepo.HTMLURL() + "/src/branch/" + util.PathEscapeSegments(pr.HeadBranch)
|
||||||
|
}
|
||||||
|
|
|
@ -301,6 +301,8 @@ func setMergeTarget(ctx *context.Context, pull *models.PullRequest) {
|
||||||
ctx.Data["HeadTarget"] = pull.MustHeadUserName() + "/" + pull.HeadRepo.Name + ":" + pull.HeadBranch
|
ctx.Data["HeadTarget"] = pull.MustHeadUserName() + "/" + pull.HeadRepo.Name + ":" + pull.HeadBranch
|
||||||
}
|
}
|
||||||
ctx.Data["BaseTarget"] = pull.BaseBranch
|
ctx.Data["BaseTarget"] = pull.BaseBranch
|
||||||
|
ctx.Data["HeadBranchHTMLURL"] = pull.GetHeadBranchHTMLURL()
|
||||||
|
ctx.Data["BaseBranchHTMLURL"] = pull.GetBaseBranchHTMLURL()
|
||||||
}
|
}
|
||||||
|
|
||||||
// PrepareMergedViewPullInfo show meta information for a merged pull request view page
|
// PrepareMergedViewPullInfo show meta information for a merged pull request view page
|
||||||
|
|
|
@ -30,23 +30,31 @@
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
{{if .Issue.IsPull}}
|
{{if .Issue.IsPull}}
|
||||||
|
{{$headHref := .HeadTarget|Escape}}
|
||||||
|
{{if .HeadBranchHTMLURL}}
|
||||||
|
{{$headHref = printf "<a href=\"%s\">%s</a>" .HeadBranchHTMLURL $headHref}}
|
||||||
|
{{end}}
|
||||||
|
{{$baseHref := .BaseTarget|Escape}}
|
||||||
|
{{if .BaseBranchHTMLURL}}
|
||||||
|
{{$baseHref = printf "<a href=\"%s\">%s</a>" .BaseBranchHTMLURL $baseHref}}
|
||||||
|
{{end}}
|
||||||
{{if .Issue.PullRequest.HasMerged}}
|
{{if .Issue.PullRequest.HasMerged}}
|
||||||
{{ $mergedStr:= TimeSinceUnix .Issue.PullRequest.MergedUnix $.Lang }}
|
{{ $mergedStr:= TimeSinceUnix .Issue.PullRequest.MergedUnix $.Lang }}
|
||||||
{{if .Issue.OriginalAuthor }}
|
{{if .Issue.OriginalAuthor }}
|
||||||
{{.Issue.OriginalAuthor}}
|
{{.Issue.OriginalAuthor}}
|
||||||
<span class="pull-desc">{{$.i18n.Tr "repo.pulls.merged_title_desc" .NumCommits (.HeadTarget|Escape) (.BaseTarget|Escape) $mergedStr | Str2html}}</span>
|
<span class="pull-desc">{{$.i18n.Tr "repo.pulls.merged_title_desc" .NumCommits $headHref $baseHref $mergedStr | Str2html}}</span>
|
||||||
{{else}}
|
{{else}}
|
||||||
<a {{if gt .Issue.PullRequest.Merger.ID 0}}href="{{.Issue.PullRequest.Merger.HomeLink}}"{{end}}>{{.Issue.PullRequest.Merger.GetDisplayName}}</a>
|
<a {{if gt .Issue.PullRequest.Merger.ID 0}}href="{{.Issue.PullRequest.Merger.HomeLink}}"{{end}}>{{.Issue.PullRequest.Merger.GetDisplayName}}</a>
|
||||||
<span class="pull-desc">{{$.i18n.Tr "repo.pulls.merged_title_desc" .NumCommits (.HeadTarget|Escape) (.BaseTarget|Escape) $mergedStr | Str2html}}</span>
|
<span class="pull-desc">{{$.i18n.Tr "repo.pulls.merged_title_desc" .NumCommits $headHref $baseHref $mergedStr | Str2html}}</span>
|
||||||
{{end}}
|
{{end}}
|
||||||
{{else}}
|
{{else}}
|
||||||
{{if .Issue.OriginalAuthor }}
|
{{if .Issue.OriginalAuthor }}
|
||||||
<span id="pull-desc" class="pull-desc">{{.Issue.OriginalAuthor}} {{$.i18n.Tr "repo.pulls.title_desc" .NumCommits (.HeadTarget|Escape) (.BaseTarget|Escape) | Str2html}}</span>
|
<span id="pull-desc" class="pull-desc">{{.Issue.OriginalAuthor}} {{$.i18n.Tr "repo.pulls.title_desc" .NumCommits $headHref $baseHref | Str2html}}</span>
|
||||||
{{else}}
|
{{else}}
|
||||||
<span id="pull-desc" class="pull-desc">
|
<span id="pull-desc" class="pull-desc">
|
||||||
<a {{if gt .Issue.Poster.ID 0}}href="{{.Issue.Poster.HomeLink}}"{{end}}>{{.Issue.Poster.GetDisplayName}}</a>
|
<a {{if gt .Issue.Poster.ID 0}}href="{{.Issue.Poster.HomeLink}}"{{end}}>{{.Issue.Poster.GetDisplayName}}</a>
|
||||||
{{$.i18n.Tr "repo.pulls.title_desc" .NumCommits (.HeadTarget|Escape) (.BaseTarget|Escape) | Str2html}}
|
{{$.i18n.Tr "repo.pulls.title_desc" .NumCommits $headHref $baseHref | Str2html}}
|
||||||
</span>
|
</span>
|
||||||
{{end}}
|
{{end}}
|
||||||
<span id="pull-desc-edit" style="display: none">
|
<span id="pull-desc-edit" style="display: none">
|
||||||
<div class="ui floating filter dropdown">
|
<div class="ui floating filter dropdown">
|
||||||
|
|
Loading…
Reference in a new issue