@@ -360,6 +360,8 @@ func NewRelease(ctx *context.Context) {
360
360
return
361
361
}
362
362
363
+ ctx .Data ["ShowCreateTagOnlyButton" ] = true
364
+
363
365
// pre-fill the form with the tag name, target branch and the existing release (if exists)
364
366
ctx .Data ["tag_target" ] = ctx .Repo .Repository .DefaultBranch
365
367
if tagName := ctx .FormString ("tag" ); tagName != "" {
@@ -376,7 +378,7 @@ func NewRelease(ctx *context.Context) {
376
378
return
377
379
}
378
380
379
- ctx .Data ["TagNameReleaseExists " ] = true
381
+ ctx .Data ["ShowCreateTagOnlyButton " ] = false
380
382
ctx .Data ["tag_name" ] = rel .TagName
381
383
ctx .Data ["tag_target" ] = rel .Target
382
384
ctx .Data ["title" ] = rel .Title
@@ -397,14 +399,17 @@ func NewReleasePost(ctx *context.Context) {
397
399
398
400
form := web .GetForm (ctx ).(* forms.NewReleaseForm )
399
401
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
402
+ // first, check whether the release exists, and prepare "ShowCreateTagOnlyButton"
403
+ // the logic should be done before the form error check to make the tmpl has correct variables
402
404
rel , err := repo_model .GetRelease (ctx , ctx .Repo .Repository .ID , form .TagName )
403
405
if err != nil && ! repo_model .IsErrReleaseNotExist (err ) {
404
406
ctx .ServerError ("GetRelease" , err )
405
407
return
406
408
}
407
- ctx .Data ["TagNameReleaseExists" ] = rel != nil
409
+
410
+ // we should still show the "tag only" button if the user clicks it, no matter the release exists or not.
411
+ // because if error occurs, end users need to have the chance to edit the name and submit the form with "tag-only" again.
412
+ ctx .Data ["ShowCreateTagOnlyButton" ] = form .TagOnly || rel == nil
408
413
409
414
// do some form checks
410
415
if ctx .HasError () {
0 commit comments