Skip to content

Commit 8f80f3e

Browse files
committed
manual merge tag ...
if: * no commits ahead default branch * not same as default branch
1 parent 8a82850 commit 8f80f3e

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

options/locale/locale_en-US.ini

+1
Original file line numberDiff line numberDiff line change
@@ -1448,6 +1448,7 @@ branch.restore_failed = Failed to restore branch '%s'.
14481448
branch.protected_deletion_failed = Branch '%s' is protected. It cannot be deleted.
14491449
branch.restore = Restore Branch '%s'
14501450
branch.download = Download Branch '%s'
1451+
branch.manual_merged = Branch was merged manually
14511452

14521453
topic.manage_topics = Manage Topics
14531454
topic.done = Done

routers/repo/branch.go

+7
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+
IsMerged bool
3132
DeletedBranch *models.DeletedBranch
3233
CommitsAhead int
3334
CommitsBehind int
@@ -203,10 +204,16 @@ func loadBranches(ctx *context.Context) []*Branch {
203204
}
204205
}
205206

207+
isMerged := true
208+
if (divergence.Ahead != 0) || (divergence.Behind == 0) || (ctx.Repo.Repository.DefaultBranch == branchName) {
209+
isMerged = false
210+
}
211+
206212
branches[i] = &Branch{
207213
Name: branchName,
208214
Commit: commit,
209215
IsProtected: isProtected,
216+
IsMerged: isMerged,
210217
CommitsAhead: divergence.Ahead,
211218
CommitsBehind: divergence.Behind,
212219
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 .IsMerged}}
79+
<div class="ui poping up purple small label" data-content="{{$.i18n.Tr "repo.branch.manual_merged"}}" data-variation="tiny inverted" data-position="top right">
80+
<i class="octicon octicon-git-pull-request"></i> {{$.i18n.Tr "repo.pulls.merged"}}
81+
</div>
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)