Skip to content

Commit 832b78e

Browse files
committed
Empty, mirror & archived repository will not allow create branch
1 parent da7f700 commit 832b78e

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

models/repo/repo.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -597,7 +597,7 @@ func (repo *Repository) IsOwnedBy(userID int64) bool {
597597

598598
// CanCreateBranch returns true if repository meets the requirements for creating new branches.
599599
func (repo *Repository) CanCreateBranch() bool {
600-
return !repo.IsMirror
600+
return !repo.IsMirror && !repo.IsArchived
601601
}
602602

603603
// CanEnablePulls returns true if repository meets the requirements of accepting pulls.

routers/web/repo/issue_view.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -990,4 +990,7 @@ func prepareIssueViewSidebarDevLinks(ctx *context.Context, issue *issues_model.I
990990
}
991991

992992
ctx.Data["AllowedRepos"] = allowedRepos
993+
ctx.Data["ShowCreateBranchLink"] = !ctx.Repo.Repository.IsEmpty &&
994+
ctx.Repo.Repository.CanCreateBranch() &&
995+
len(allowedRepos) > 0 && !issue.IsClosed
993996
}

templates/repo/issue/sidebar/development.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<span class="text"><strong>{{ctx.Locale.Tr "repo.issues.development"}}</strong></span>
55
<div class="ui devlinks list">
66
{{/* AllowedRepos not empty means login user can create new branch in some of the repositories */}}
7-
{{if and (not .Issue.IsClosed) .AllowedRepos}}
7+
{{if .ShowCreateBranchLink}}
88
<div class="tw-items-center">
99
<a class="tw-mt-1 fluid ui show-modal" data-modal="#create_branch">{{ctx.Locale.Tr "repo.branch.new_branch"}}</a>
1010
</div>

0 commit comments

Comments
 (0)