Skip to content

Commit ed7245f

Browse files
authored
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)
1 parent 950c93a commit ed7245f

File tree

4 files changed

+9
-2
lines changed

4 files changed

+9
-2
lines changed

options/locale/locale_en-US.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2308,6 +2308,7 @@ release.tag_helper = Choose an existing tag or create a new tag.
23082308
release.tag_helper_new = New tag. This tag will be created from the target.
23092309
release.tag_helper_existing = Existing tag.
23102310
release.title = Title
2311+
release.title_empty = Title cannot be empty.
23112312
release.content = Content
23122313
release.prerelease_desc = Mark as Pre-Release
23132314
release.prerelease_helper = Mark this release unsuitable for production use.

routers/web/repo/release.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,12 @@ func NewReleasePost(ctx *context.Context) {
360360
return
361361
}
362362

363+
// Title of release cannot be empty
364+
if len(form.TagOnly) == 0 && len(form.Title) == 0 {
365+
ctx.RenderWithErr(ctx.Tr("repo.release.title_empty"), tplReleaseNew, &form)
366+
return
367+
}
368+
363369
var attachmentUUIDs []string
364370
if setting.Attachment.Enabled {
365371
attachmentUUIDs = form.Files

services/forms/repo_form.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -693,7 +693,7 @@ type UpdateAllowEditsForm struct {
693693
type NewReleaseForm struct {
694694
TagName string `binding:"Required;GitRefName;MaxSize(255)"`
695695
Target string `form:"tag_target" binding:"Required;MaxSize(255)"`
696-
Title string `binding:"Required;MaxSize(255)"`
696+
Title string `binding:"MaxSize(255)"`
697697
Content string
698698
Draft string
699699
TagOnly string

templates/repo/release/new.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
<div class="eleven wide column">
4848
<div class="field {{if .Err_Title}}error{{end}}">
4949
<label>{{.locale.Tr "repo.release.title"}}</label>
50-
<input name="title" placeholder="{{.locale.Tr "repo.release.title"}}" value="{{.title}}" autofocus required maxlength="255">
50+
<input name="title" placeholder="{{.locale.Tr "repo.release.title"}}" value="{{.title}}" autofocus maxlength="255">
5151
</div>
5252
<div class="field">
5353
<label>{{.locale.Tr "repo.release.content"}}</label>

0 commit comments

Comments
 (0)