From df22f8da5f051548843403f0b413e90d08c9ff28 Mon Sep 17 00:00:00 2001 From: Solomon Victorino Date: Tue, 16 Jul 2024 14:42:35 +0000 Subject: [PATCH] fix: preserve object format dropdown options on /repo/create error (#4360) To reproduce: - make the repo creation form return with an error, like a duplicate name - click on the Object format dropdown - the options are missing as the listbox is empty Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/4360 Reviewed-by: Earl Warren Co-authored-by: Solomon Victorino Co-committed-by: Solomon Victorino --- routers/web/repo/repo.go | 2 + templates/repo/create.tmpl | 2 +- tests/integration/html_helper.go | 32 +++++++++++ tests/integration/repo_generate_test.go | 74 ++++++++++++++++++------- 4 files changed, 89 insertions(+), 21 deletions(-) diff --git a/routers/web/repo/repo.go b/routers/web/repo/repo.go index 4d17be3758..711a1e1e12 100644 --- a/routers/web/repo/repo.go +++ b/routers/web/repo/repo.go @@ -231,6 +231,8 @@ func CreatePost(ctx *context.Context) { ctx.Data["CanCreateRepo"] = ctx.Doer.CanCreateRepo() ctx.Data["MaxCreationLimit"] = ctx.Doer.MaxCreationLimit() + ctx.Data["SupportedObjectFormats"] = git.SupportedObjectFormats + ctx.Data["DefaultObjectFormat"] = git.Sha1ObjectFormat ctxUser := checkContextUser(ctx, form.UID) if ctx.Written() { diff --git a/templates/repo/create.tmpl b/templates/repo/create.tmpl index 3afd978ee9..d3a11e7ed5 100644 --- a/templates/repo/create.tmpl +++ b/templates/repo/create.tmpl @@ -69,7 +69,7 @@