@@ -397,13 +397,16 @@ func NewReleasePost(ctx *context.Context) {
397397
398398 form := web .GetForm (ctx ).(* forms.NewReleaseForm )
399399
400+ // first, check whether the release exists,
401+ // it should be done before the form error check, because the tmpl needs "TagNameReleaseExists" to show/hide the "tag only" button
400402 rel , err := repo_model .GetRelease (ctx , ctx .Repo .Repository .ID , form .TagName )
401403 if err != nil && ! repo_model .IsErrReleaseNotExist (err ) {
402404 ctx .ServerError ("GetRelease" , err )
403405 return
404406 }
405407 ctx .Data ["TagNameReleaseExists" ] = rel != nil
406408
409+ // do some form checks
407410 if ctx .HasError () {
408411 ctx .HTML (http .StatusOK , tplReleaseNew )
409412 return
@@ -414,8 +417,8 @@ func NewReleasePost(ctx *context.Context) {
414417 return
415418 }
416419
417- // Title of release cannot be empty
418420 if ! form .TagOnly && form .Title == "" {
421+ // if not "tag only", then the title of the release cannot be empty
419422 ctx .RenderWithErr (ctx .Tr ("repo.release.title_empty" ), tplReleaseNew , & form )
420423 return
421424 }
@@ -436,6 +439,7 @@ func NewReleasePost(ctx *context.Context) {
436439 }
437440 }
438441
442+ // prepare the git message for creating a new tag
439443 newTagMsg := ""
440444 if form .Title != "" && form .AddTagMsg {
441445 newTagMsg = form .Title + "\n \n " + form .Content
@@ -452,12 +456,9 @@ func NewReleasePost(ctx *context.Context) {
452456 return
453457 }
454458
455- var attachmentUUIDs []string
456- if setting .Attachment .Enabled {
457- attachmentUUIDs = form .Files
458- }
459+ attachmentUUIDs := util .Iif (setting .Attachment .Enabled , form .Files , nil )
459460
460- // no release, create a new release
461+ // no existing release, create a new release
461462 if rel == nil {
462463 rel = & repo_model.Release {
463464 RepoID : ctx .Repo .Repository .ID ,
0 commit comments