Empty, mirror & archived repository will not allow create branch

This commit is contained in:
Lunny Xiao 2024-12-09 18:43:36 -08:00
parent da7f700d28
commit 832b78eb69
No known key found for this signature in database
GPG Key ID: C3B7C91B632F738A
3 changed files with 5 additions and 2 deletions

View File

@ -597,7 +597,7 @@ func (repo *Repository) IsOwnedBy(userID int64) bool {
// CanCreateBranch returns true if repository meets the requirements for creating new branches.
func (repo *Repository) CanCreateBranch() bool {
return !repo.IsMirror
return !repo.IsMirror && !repo.IsArchived
}
// CanEnablePulls returns true if repository meets the requirements of accepting pulls.

View File

@ -990,4 +990,7 @@ func prepareIssueViewSidebarDevLinks(ctx *context.Context, issue *issues_model.I
}
ctx.Data["AllowedRepos"] = allowedRepos
ctx.Data["ShowCreateBranchLink"] = !ctx.Repo.Repository.IsEmpty &&
ctx.Repo.Repository.CanCreateBranch() &&
len(allowedRepos) > 0 && !issue.IsClosed
}

View File

@ -4,7 +4,7 @@
<span class="text"><strong>{{ctx.Locale.Tr "repo.issues.development"}}</strong></span>
<div class="ui devlinks list">
{{/* AllowedRepos not empty means login user can create new branch in some of the repositories */}}
{{if and (not .Issue.IsClosed) .AllowedRepos}}
{{if .ShowCreateBranchLink}}
<div class="tw-items-center">
<a class="tw-mt-1 fluid ui show-modal" data-modal="#create_branch">{{ctx.Locale.Tr "repo.branch.new_branch"}}</a>
</div>