@@ -397,13 +397,16 @@ func NewReleasePost(ctx *context.Context) {
397
397
398
398
form := web .GetForm (ctx ).(* forms.NewReleaseForm )
399
399
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
400
402
rel , err := repo_model .GetRelease (ctx , ctx .Repo .Repository .ID , form .TagName )
401
403
if err != nil && ! repo_model .IsErrReleaseNotExist (err ) {
402
404
ctx .ServerError ("GetRelease" , err )
403
405
return
404
406
}
405
407
ctx .Data ["TagNameReleaseExists" ] = rel != nil
406
408
409
+ // do some form checks
407
410
if ctx .HasError () {
408
411
ctx .HTML (http .StatusOK , tplReleaseNew )
409
412
return
@@ -414,8 +417,8 @@ func NewReleasePost(ctx *context.Context) {
414
417
return
415
418
}
416
419
417
- // Title of release cannot be empty
418
420
if ! form .TagOnly && form .Title == "" {
421
+ // if not "tag only", then the title of the release cannot be empty
419
422
ctx .RenderWithErr (ctx .Tr ("repo.release.title_empty" ), tplReleaseNew , & form )
420
423
return
421
424
}
@@ -436,6 +439,7 @@ func NewReleasePost(ctx *context.Context) {
436
439
}
437
440
}
438
441
442
+ // prepare the git message for creating a new tag
439
443
newTagMsg := ""
440
444
if form .Title != "" && form .AddTagMsg {
441
445
newTagMsg = form .Title + "\n \n " + form .Content
@@ -452,12 +456,9 @@ func NewReleasePost(ctx *context.Context) {
452
456
return
453
457
}
454
458
455
- var attachmentUUIDs []string
456
- if setting .Attachment .Enabled {
457
- attachmentUUIDs = form .Files
458
- }
459
+ attachmentUUIDs := util .Iif (setting .Attachment .Enabled , form .Files , nil )
459
460
460
- // no release, create a new release
461
+ // no existing release, create a new release
461
462
if rel == nil {
462
463
rel = & repo_model.Release {
463
464
RepoID : ctx .Repo .Repository .ID ,
0 commit comments