From 733c898a907b23fa9e0c1bf108be5c5d9f9f7eb0 Mon Sep 17 00:00:00 2001 From: 6543 <24977596+6543@users.noreply.github.com> Date: Tue, 15 Oct 2019 00:40:17 +0200 Subject: [PATCH] [Branch View] Add Included TAG (#8449) * included message * add property IsIncluded * Add Orange Lable --- options/locale/locale_en-US.ini | 2 ++ routers/repo/branch.go | 4 ++++ templates/repo/branch/list.tmpl | 6 +++++- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index 4a92b0803..b5a3d8c59 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -1453,6 +1453,8 @@ branch.restore_failed = Failed to restore branch '%s'. branch.protected_deletion_failed = Branch '%s' is protected. It cannot be deleted. branch.restore = Restore Branch '%s' branch.download = Download Branch '%s' +branch.included_desc = This branch is part of the default branch +branch.included = Included topic.manage_topics = Manage Topics topic.done = Done diff --git a/routers/repo/branch.go b/routers/repo/branch.go index 5d7851849..0c06de3ea 100644 --- a/routers/repo/branch.go +++ b/routers/repo/branch.go @@ -28,6 +28,7 @@ type Branch struct { Commit *git.Commit IsProtected bool IsDeleted bool + IsIncluded bool DeletedBranch *models.DeletedBranch CommitsAhead int CommitsBehind int @@ -203,10 +204,13 @@ func loadBranches(ctx *context.Context) []*Branch { } } + isIncluded := divergence.Ahead == 0 && ctx.Repo.Repository.DefaultBranch != branchName + branches[i] = &Branch{ Name: branchName, Commit: commit, IsProtected: isProtected, + IsIncluded: isIncluded, CommitsAhead: divergence.Ahead, CommitsBehind: divergence.Behind, LatestPullRequest: pr, diff --git a/templates/repo/branch/list.tmpl b/templates/repo/branch/list.tmpl index 9c53f4e67..26493298d 100644 --- a/templates/repo/branch/list.tmpl +++ b/templates/repo/branch/list.tmpl @@ -75,7 +75,11 @@ {{if not .LatestPullRequest}} - {{if and (not .IsDeleted) $.AllowsPulls (gt .CommitsAhead 0)}} + {{if .IsIncluded}} + + {{$.i18n.Tr "repo.branch.included"}} + + {{else if and (not .IsDeleted) $.AllowsPulls (gt .CommitsAhead 0)}}