Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Branch View] Add Included TAG #8449

Merged
merged 4 commits into from
Oct 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions options/locale/locale_en-US.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions routers/repo/branch.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ type Branch struct {
Commit *git.Commit
IsProtected bool
IsDeleted bool
IsIncluded bool
DeletedBranch *models.DeletedBranch
CommitsAhead int
CommitsBehind int
Expand Down Expand Up @@ -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,
Expand Down
6 changes: 5 additions & 1 deletion templates/repo/branch/list.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,11 @@
</td>
<td class="two wide right aligned">
{{if not .LatestPullRequest}}
{{if and (not .IsDeleted) $.AllowsPulls (gt .CommitsAhead 0)}}
{{if .IsIncluded}}
<a class="ui poping up orange small label" data-content="{{$.i18n.Tr "repo.branch.included_desc"}}" data-variation="tiny inverted" data-position="top right">
6543 marked this conversation as resolved.
Show resolved Hide resolved
<i class="octicon octicon-git-pull-request"></i> {{$.i18n.Tr "repo.branch.included"}}
</a>
{{else if and (not .IsDeleted) $.AllowsPulls (gt .CommitsAhead 0)}}
<a href="{{$.RepoLink}}/compare/{{$.DefaultBranch | EscapePound}}...{{if ne $.Repository.Owner.Name $.Owner.Name}}{{$.Owner.Name}}:{{end}}{{.Name | EscapePound}}">
<button id="new-pull-request" class="ui compact basic button">{{$.i18n.Tr "repo.pulls.compare_changes"}}</button>
</a>
Expand Down