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)
This commit is contained in:
Zettat123 2023-04-07 09:44:52 +08:00 committed by GitHub
parent 950c93a66a
commit ed7245f997
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 9 additions and 2 deletions

View file

@ -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_new = New tag. This tag will be created from the target.
release.tag_helper_existing = Existing tag. release.tag_helper_existing = Existing tag.
release.title = Title release.title = Title
release.title_empty = Title cannot be empty.
release.content = Content release.content = Content
release.prerelease_desc = Mark as Pre-Release release.prerelease_desc = Mark as Pre-Release
release.prerelease_helper = Mark this release unsuitable for production use. release.prerelease_helper = Mark this release unsuitable for production use.

View file

@ -360,6 +360,12 @@ func NewReleasePost(ctx *context.Context) {
return 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 var attachmentUUIDs []string
if setting.Attachment.Enabled { if setting.Attachment.Enabled {
attachmentUUIDs = form.Files attachmentUUIDs = form.Files

View file

@ -693,7 +693,7 @@ type UpdateAllowEditsForm struct {
type NewReleaseForm struct { type NewReleaseForm struct {
TagName string `binding:"Required;GitRefName;MaxSize(255)"` TagName string `binding:"Required;GitRefName;MaxSize(255)"`
Target string `form:"tag_target" binding:"Required;MaxSize(255)"` Target string `form:"tag_target" binding:"Required;MaxSize(255)"`
Title string `binding:"Required;MaxSize(255)"` Title string `binding:"MaxSize(255)"`
Content string Content string
Draft string Draft string
TagOnly string TagOnly string

View file

@ -47,7 +47,7 @@
<div class="eleven wide column"> <div class="eleven wide column">
<div class="field {{if .Err_Title}}error{{end}}"> <div class="field {{if .Err_Title}}error{{end}}">
<label>{{.locale.Tr "repo.release.title"}}</label> <label>{{.locale.Tr "repo.release.title"}}</label>
<input name="title" placeholder="{{.locale.Tr "repo.release.title"}}" value="{{.title}}" autofocus required maxlength="255"> <input name="title" placeholder="{{.locale.Tr "repo.release.title"}}" value="{{.title}}" autofocus maxlength="255">
</div> </div>
<div class="field"> <div class="field">
<label>{{.locale.Tr "repo.release.content"}}</label> <label>{{.locale.Tr "repo.release.content"}}</label>