From 8d32ca32c2d2b71de08a53208df66aa6aecfddc7 Mon Sep 17 00:00:00 2001 From: Otto Richter Date: Fri, 27 Dec 2024 16:11:45 +0100 Subject: [PATCH] New repo: Rework initialization - only show settings when ticked - only offer README selection when there are multiple options --- options/locale/locale_en-US.ini | 3 +- templates/repo/create.tmpl | 64 ++++--------------------- templates/repo/create_init.tmpl | 56 ++++++++++++++++++++++ tests/integration/repo_generate_test.go | 2 +- 4 files changed, 67 insertions(+), 58 deletions(-) create mode 100644 templates/repo/create_init.tmpl diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index 460f318292..3f9cad7051 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -1103,7 +1103,8 @@ object_format_helper = Object format of the repository. Cannot be changed later. readme = README readme_helper = Select a README file template readme_helper_desc = This is the place where you can write a complete description for your project. -auto_init = Initialize repository (Adds .gitignore, License and README) +auto_init = Initialize repository +auto_init_description = Start the Git history with a README and optionally add License and .gitignore files. create_repo = Create repository default_branch = Default branch default_branch_label = default diff --git a/templates/repo/create.tmpl b/templates/repo/create.tmpl index 8212033242..7ee8587435 100644 --- a/templates/repo/create.tmpl +++ b/templates/repo/create.tmpl @@ -29,69 +29,21 @@
+
+ {{ctx.Locale.Tr "repo.auto_init"}} + {{template "repo/create_init" .}} +
+
{{ctx.Locale.Tr "repo.new_advanced"}}
{{ctx.Locale.Tr "repo.new_advanced_expand"}} {{template "repo/create_advanced" .}}
- - -
- - - {{ctx.Locale.Tr "repo.repo_gitignore_helper_desc"}} -
-
- - - {{ctx.Locale.Tr "repo.license_helper_desc" "https://choosealicense.com/"}} -
- -
- - - {{ctx.Locale.Tr "repo.readme_helper_desc"}} -
-
-
- - -
-
-
-
-
- -
+ diff --git a/templates/repo/create_init.tmpl b/templates/repo/create_init.tmpl new file mode 100644 index 0000000000..729b44c8e6 --- /dev/null +++ b/templates/repo/create_init.tmpl @@ -0,0 +1,56 @@ + + +
+ + + + + {{$supportedReadmesLength := len .Readmes}} + {{/* Only offer README selection if there is an actual choice */}} + {{if ge $supportedReadmesLength 2}} + + {{else}} + + {{end}} +
diff --git a/tests/integration/repo_generate_test.go b/tests/integration/repo_generate_test.go index 4bd9f32119..bcee0df417 100644 --- a/tests/integration/repo_generate_test.go +++ b/tests/integration/repo_generate_test.go @@ -43,7 +43,7 @@ func assertRepoCreateForm(t *testing.T, htmlDoc *HTMLDoc, owner *user_model.User // the template menu is loaded client-side, so don't assert the option exists assert.Equal(t, templateID, htmlDoc.GetInputValueByName("repo_template"), "Unexpected repo_template selection") - for _, name := range []string{"issue_labels", "gitignores", "license", "readme", "object_format_name"} { + for _, name := range []string{"issue_labels", "gitignores", "license", "object_format_name"} { htmlDoc.AssertDropdownHasOptions(t, name) } }