Skip to content

Commit

Permalink
Title can be empty when creating tag only (#23917) (#23961)
Browse files Browse the repository at this point in the history
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 <zettat123@gmail.com>
  • Loading branch information
GiteaBot and Zettat123 committed Apr 7, 2023
1 parent 085b563 commit 1b8ecd1
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions options/locale/locale_en-US.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 6 additions & 0 deletions routers/web/repo/release.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion services/forms/repo_form.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion templates/repo/release/new.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
<div class="eleven wide column">
<div class="field {{if .Err_Title}}error{{end}}">
<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 class="field content-editor">
<label>{{.locale.Tr "repo.release.content"}}</label>
Expand Down

0 comments on commit 1b8ecd1

Please sign in to comment.