Skip to content

Commit 7ce388f

Browse files
committed
Add line-through for deleted branch on pull request view page
1 parent ad22300 commit 7ce388f

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

routers/web/repo/pull.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,7 @@ func PrepareViewPullInfo(ctx *context.Context, issue *issues_model.Issue) *git.C
348348
}
349349

350350
if !baseGitRepo.IsBranchExist(pull.BaseBranch) {
351+
ctx.Data["BaseBranchNotExist"] = true
351352
ctx.Data["IsPullRequestBroken"] = true
352353
ctx.Data["BaseTarget"] = pull.BaseBranch
353354
ctx.Data["HeadTarget"] = pull.HeadBranch
@@ -431,6 +432,7 @@ func PrepareViewPullInfo(ctx *context.Context, issue *issues_model.Issue) *git.C
431432
ctx.Data["GetCommitMessages"] = pull_service.GetSquashMergeCommitMessages(ctx, pull)
432433
} else {
433434
ctx.Data["GetCommitMessages"] = ""
435+
ctx.Data["HeadBranchNotExist"] = true
434436
}
435437

436438
sha, err := baseGitRepo.GetRefCommitID(pull.GetGitRefName())

templates/repo/issue/view_title.tmpl

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,11 @@
5656
{{if .Issue.IsPull}}
5757
{{$headHref := .HeadTarget}}
5858
{{if .HeadBranchLink}}
59-
{{$headHref = HTMLFormat `<a href="%s">%s</a> <button class="btn interact-fg" data-tooltip-content="%s" data-clipboard-text="%s">%s</button>` .HeadBranchLink $headHref (ctx.Locale.Tr "copy_branch") .HeadTarget (svg "octicon-copy" 14)}}
59+
{{if .HeadBranchNotExist}}
60+
{{$headHref = HTMLFormat `<span class="tw-line-through" data-tooltip-content="%s">%s</span>` (ctx.Locale.Tr "form.target_branch_not_exist") $headHref}}
61+
{{else}}
62+
{{$headHref = HTMLFormat `<a href="%s">%s</a> <button class="btn interact-fg" data-tooltip-content="%s" data-clipboard-text="%s">%s</button>` .HeadBranchLink $headHref (ctx.Locale.Tr "copy_branch") .HeadTarget (svg "octicon-copy" 14)}}
63+
{{end}}
6064
{{else}}
6165
{{if .Issue.PullRequest.IsAgitFlow}}
6266
{{$headHref = HTMLFormat `%s <a href="%s" target="_blank"><span class="ui label basic tiny" data-tooltip-content="%s">AGit</span></a>` $headHref "https://docs.gitea.com/usage/agit" (ctx.Locale.Tr "repo.pull.agit_documentation")}}
@@ -66,8 +70,13 @@
6670
{{end}}
6771
{{$baseHref := .BaseTarget}}
6872
{{if .BaseBranchLink}}
69-
{{$baseHref = HTMLFormat `<a href="%s">%s</a>` .BaseBranchLink $baseHref}}
73+
{{if .BaseBranchNotExist}}
74+
{{$baseHref = HTMLFormat `<span class="tw-line-through" data-tooltip-content="%s">%s</span>` (ctx.Locale.Tr "form.target_branch_not_exist") $baseHref}}
75+
{{else}}
76+
{{$baseHref = HTMLFormat `<a href="%s">%s</a>` .BaseBranchLink $baseHref}}
77+
{{end}}
7078
{{end}}
79+
7180
{{if .Issue.PullRequest.HasMerged}}
7281
{{$mergedStr:= DateUtils.TimeSince .Issue.PullRequest.MergedUnix}}
7382
{{if .Issue.OriginalAuthor}}

0 commit comments

Comments
 (0)