From 09f7dbecdad19e728db67aeb63e7547ae35e5046 Mon Sep 17 00:00:00 2001 From: John Moon Date: Wed, 14 May 2025 23:26:12 +0000 Subject: [PATCH] fix: Remove "create branch" button on mirrored repos (#7640) Currently, if you have a mirrored repo, the button on the "branches" page to create a new branch is available to be pressed. Once you name your new branch and click submit, you get a 404 page that doesn't explain what went wrong. As new branch creation is not supported on mirrored repos, let's just take that button away if the repo is a mirror. This is already done for archived repos, so we just need to add another check. Fixes #7639. Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/7640 Reviewed-by: Otto Co-authored-by: John Moon Co-committed-by: John Moon --- models/fixtures/repository.yml | 1 + templates/repo/branch/list.tmpl | 4 ++-- tests/integration/repo_branch_test.go | 25 +++++++++++++++++++++++++ 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/models/fixtures/repository.yml b/models/fixtures/repository.yml index f7aaad1f31..0ba4d06e14 100644 --- a/models/fixtures/repository.yml +++ b/models/fixtures/repository.yml @@ -132,6 +132,7 @@ owner_name: org3 lower_name: repo5 name: repo5 + default_branch: master num_watches: 0 num_stars: 0 num_forks: 0 diff --git a/templates/repo/branch/list.tmpl b/templates/repo/branch/list.tmpl index c60017ba87..fe945324ea 100644 --- a/templates/repo/branch/list.tmpl +++ b/templates/repo/branch/list.tmpl @@ -30,7 +30,7 @@

{{svg "octicon-git-commit" 16 "tw-mr-1"}}{{ShortSha .DefaultBranchBranch.DBBranch.CommitID}} · {{RenderCommitMessage $.Context .DefaultBranchBranch.DBBranch.CommitMessage (.Repository.ComposeMetas ctx)}} · {{ctx.Locale.Tr "org.repo_updated" (DateUtils.TimeSince .DefaultBranchBranch.DBBranch.CommitTime)}}{{if .DefaultBranchBranch.DBBranch.Pusher}}  {{template "shared/user/avatarlink" dict "user" .DefaultBranchBranch.DBBranch.Pusher}}{{template "shared/user/namelink" .DefaultBranchBranch.DBBranch.Pusher}}{{end}}

- {{if and $.IsWriter (not $.Repository.IsArchived) (not .IsDeleted)}} + {{if and $.IsWriter (not $.Repository.IsArchived) (not $.Repository.IsMirror) (not .IsDeleted)}}