From 832b78eb698b1b435b320cdcee535c0a08703a70 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Mon, 9 Dec 2024 18:43:36 -0800 Subject: [PATCH] Empty, mirror & archived repository will not allow create branch --- models/repo/repo.go | 2 +- routers/web/repo/issue_view.go | 3 +++ templates/repo/issue/sidebar/development.tmpl | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/models/repo/repo.go b/models/repo/repo.go index 8d211caf40..ee9cbc0847 100644 --- a/models/repo/repo.go +++ b/models/repo/repo.go @@ -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. diff --git a/routers/web/repo/issue_view.go b/routers/web/repo/issue_view.go index 3c31a41a3d..0cb9a70eab 100644 --- a/routers/web/repo/issue_view.go +++ b/routers/web/repo/issue_view.go @@ -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 } diff --git a/templates/repo/issue/sidebar/development.tmpl b/templates/repo/issue/sidebar/development.tmpl index 277dc8cc42..522fd99a32 100644 --- a/templates/repo/issue/sidebar/development.tmpl +++ b/templates/repo/issue/sidebar/development.tmpl @@ -4,7 +4,7 @@ {{ctx.Locale.Tr "repo.issues.development"}}