From 1b8ecd179bdb58427b99c2c2eb9ad5a45abf7055 Mon Sep 17 00:00:00 2001 From: Giteabot Date: Fri, 7 Apr 2023 08:13:57 -0400 Subject: [PATCH] Title can be empty when creating tag only (#23917) (#23961) Backport #23917 by @Zettat123 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) Co-authored-by: Zettat123 --- 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 081ffb7abf..5154aadb68 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -2288,6 +2288,7 @@ release.tag_name = Tag name release.target = Target release.tag_helper = Choose an existing tag or create a new 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 e969fdc5ab..63c8797fe5 100644 --- a/routers/web/repo/release.go +++ b/routers/web/repo/release.go @@ -357,6 +357,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 e9645b5ab7..a08f9bc9e4 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 37d7ca0321..0cac670522 100644 --- a/templates/repo/release/new.tmpl +++ b/templates/repo/release/new.tmpl @@ -42,7 +42,7 @@
- +