Skip to content

Commit 733c898

Browse files
6543zeripath
authored andcommitted
[Branch View] Add Included TAG (#8449)
* included message * add property IsIncluded * Add Orange Lable
1 parent 0be992a commit 733c898

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

options/locale/locale_en-US.ini

+2
Original file line numberDiff line numberDiff line change
@@ -1453,6 +1453,8 @@ branch.restore_failed = Failed to restore branch '%s'.
14531453
branch.protected_deletion_failed = Branch '%s' is protected. It cannot be deleted.
14541454
branch.restore = Restore Branch '%s'
14551455
branch.download = Download Branch '%s'
1456+
branch.included_desc = This branch is part of the default branch
1457+
branch.included = Included
14561458

14571459
topic.manage_topics = Manage Topics
14581460
topic.done = Done

routers/repo/branch.go

+4
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ type Branch struct {
2828
Commit *git.Commit
2929
IsProtected bool
3030
IsDeleted bool
31+
IsIncluded bool
3132
DeletedBranch *models.DeletedBranch
3233
CommitsAhead int
3334
CommitsBehind int
@@ -203,10 +204,13 @@ func loadBranches(ctx *context.Context) []*Branch {
203204
}
204205
}
205206

207+
isIncluded := divergence.Ahead == 0 && ctx.Repo.Repository.DefaultBranch != branchName
208+
206209
branches[i] = &Branch{
207210
Name: branchName,
208211
Commit: commit,
209212
IsProtected: isProtected,
213+
IsIncluded: isIncluded,
210214
CommitsAhead: divergence.Ahead,
211215
CommitsBehind: divergence.Behind,
212216
LatestPullRequest: pr,

templates/repo/branch/list.tmpl

+5-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,11 @@
7575
</td>
7676
<td class="two wide right aligned">
7777
{{if not .LatestPullRequest}}
78-
{{if and (not .IsDeleted) $.AllowsPulls (gt .CommitsAhead 0)}}
78+
{{if .IsIncluded}}
79+
<a class="ui poping up orange small label" data-content="{{$.i18n.Tr "repo.branch.included_desc"}}" data-variation="tiny inverted" data-position="top right">
80+
<i class="octicon octicon-git-pull-request"></i> {{$.i18n.Tr "repo.branch.included"}}
81+
</a>
82+
{{else if and (not .IsDeleted) $.AllowsPulls (gt .CommitsAhead 0)}}
7983
<a href="{{$.RepoLink}}/compare/{{$.DefaultBranch | EscapePound}}...{{if ne $.Repository.Owner.Name $.Owner.Name}}{{$.Owner.Name}}:{{end}}{{.Name | EscapePound}}">
8084
<button id="new-pull-request" class="ui compact basic button">{{$.i18n.Tr "repo.pulls.compare_changes"}}</button>
8185
</a>

0 commit comments

Comments
 (0)