File opensuse-preselect-defaults-on-repo-create-page.patch of Package gitea
From 46f296f5cb87a219c3478e3dd07d2231050d5d76 Mon Sep 17 00:00:00 2001
From: Elisei Roca <eroca@suse.de>
Date: Fri, 19 Dec 2025 12:47:38 +0100
Subject: [PATCH] Preselect defaults on repo create page
- Set pool/new_package as the template
- Take git content from the template
- Default object format to sha256 when no template is selected
---
routers/web/repo/repo.go | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/routers/web/repo/repo.go b/routers/web/repo/repo.go
index 2c137b64ab..e1ca57042c 100644
--- a/routers/web/repo/repo.go
+++ b/routers/web/repo/repo.go
@@ -152,7 +152,16 @@ func createCommon(ctx *context.Context) {
ctx.Data["CanCreateRepoInDoer"] = ctx.Doer.CanCreateRepoIn(ctx.Doer)
ctx.Data["MaxCreationLimitOfDoer"] = ctx.Doer.MaxCreationLimit()
ctx.Data["SupportedObjectFormats"] = git.DefaultFeatures().SupportedObjectFormats
- ctx.Data["DefaultObjectFormat"] = git.Sha1ObjectFormat
+ ctx.Data["DefaultObjectFormat"] = git.Sha256ObjectFormat
+ user, err := user_model.GetUserByName(ctx, "pool")
+ if err == nil {
+ templateRepo, err := repo_model.GetRepositoryByName(ctx, user.ID, "new_package")
+ if err == nil {
+ ctx.Data["repo_template"] = templateRepo.ID
+ ctx.Data["repo_template_name"] = templateRepo.Name
+ ctx.Data["git_content"] = true
+ }
+ }
}
// Create render creating repository page
@@ -167,7 +176,9 @@ func Create(ctx *context.Context) {
ctx.Data["readme"] = "Default"
ctx.Data["private"] = getRepoPrivate(ctx)
ctx.Data["default_branch"] = setting.Repository.DefaultBranch
- ctx.Data["repo_template_name"] = ctx.Tr("repo.template_select")
+ if ctx.Data["repo_template"] == nil {
+ ctx.Data["repo_template_name"] = ctx.Tr("repo.template_select")
+ }
templateID := ctx.FormInt64("template_id")
if templateID > 0 {
--
2.52.0