From ed7245f997e980fe5daa9e0d298539bc5e62ac59 Mon Sep 17 00:00:00 2001 From: Zettat123 Date: Fri, 7 Apr 2023 09:44:52 +0800 Subject: [PATCH] Title can be empty when creating tag only (#23917) Fixes #23809 Make the title not required. If the title is empty when creating release (not tag), an error message will be displayed. ![image](https://user-images.githubusercontent.com/15528715/229761056-c52e338b-5f25-4d7d-bb44-2cb0304abcee.png) --- options/locale/locale_en-US.ini | 1 + routers/web/repo/release.go | 6 ++++++ services/forms/repo_form.go | 2 +- templates/repo/release/new.tmpl | 2 +- 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index 4e711ffad..a9617541f 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -2308,6 +2308,7 @@ release.tag_helper = Choose an existing tag or create a new tag. release.tag_helper_new = New tag. This tag will be created from the target. release.tag_helper_existing = Existing tag. release.title = Title +release.title_empty = Title cannot be empty. release.content = Content release.prerelease_desc = Mark as Pre-Release release.prerelease_helper = Mark this release unsuitable for production use. diff --git a/routers/web/repo/release.go b/routers/web/repo/release.go index 5083056eb..14ef1372c 100644 --- a/routers/web/repo/release.go +++ b/routers/web/repo/release.go @@ -360,6 +360,12 @@ func NewReleasePost(ctx *context.Context) { return } + // Title of release cannot be empty + if len(form.TagOnly) == 0 && len(form.Title) == 0 { + ctx.RenderWithErr(ctx.Tr("repo.release.title_empty"), tplReleaseNew, &form) + return + } + var attachmentUUIDs []string if setting.Attachment.Enabled { attachmentUUIDs = form.Files diff --git a/services/forms/repo_form.go b/services/forms/repo_form.go index 3bd073c07..41d7dc7d2 100644 --- a/services/forms/repo_form.go +++ b/services/forms/repo_form.go @@ -693,7 +693,7 @@ type UpdateAllowEditsForm struct { type NewReleaseForm struct { TagName string `binding:"Required;GitRefName;MaxSize(255)"` Target string `form:"tag_target" binding:"Required;MaxSize(255)"` - Title string `binding:"Required;MaxSize(255)"` + Title string `binding:"MaxSize(255)"` Content string Draft string TagOnly string diff --git a/templates/repo/release/new.tmpl b/templates/repo/release/new.tmpl index ea5c70e74..cd702d6aa 100644 --- a/templates/repo/release/new.tmpl +++ b/templates/repo/release/new.tmpl @@ -47,7 +47,7 @@
- +