Skip to content

Commit 1b8ecd1

Browse files
GiteaBotZettat123
andauthored
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 <[email protected]>
1 parent 085b563 commit 1b8ecd1

File tree

4 files changed

+9
-2
lines changed

4 files changed

+9
-2
lines changed

options/locale/locale_en-US.ini

+1
Original file line numberDiff line numberDiff line change
@@ -2288,6 +2288,7 @@ release.tag_name = Tag name
22882288
release.target = Target
22892289
release.tag_helper = Choose an existing tag or create a new tag.
22902290
release.title = Title
2291+
release.title_empty = Title cannot be empty.
22912292
release.content = Content
22922293
release.prerelease_desc = Mark as Pre-Release
22932294
release.prerelease_helper = Mark this release unsuitable for production use.

routers/web/repo/release.go

+6
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,12 @@ func NewReleasePost(ctx *context.Context) {
357357
return
358358
}
359359

360+
// Title of release cannot be empty
361+
if len(form.TagOnly) == 0 && len(form.Title) == 0 {
362+
ctx.RenderWithErr(ctx.Tr("repo.release.title_empty"), tplReleaseNew, &form)
363+
return
364+
}
365+
360366
var attachmentUUIDs []string
361367
if setting.Attachment.Enabled {
362368
attachmentUUIDs = form.Files

services/forms/repo_form.go

+1-1
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

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
<div class="eleven wide column">
4343
<div class="field {{if .Err_Title}}error{{end}}">
4444
<label>{{.locale.Tr "repo.release.title"}}</label>
45-
<input name="title" placeholder="{{.locale.Tr "repo.release.title"}}" value="{{.title}}" autofocus required maxlength="255">
45+
<input name="title" placeholder="{{.locale.Tr "repo.release.title"}}" value="{{.title}}" autofocus maxlength="255">
4646
</div>
4747
<div class="field content-editor">
4848
<label>{{.locale.Tr "repo.release.content"}}</label>

0 commit comments

Comments
 (0)