]> source.dussan.org Git - gitea.git/commitdiff
Check if the release is converted from the tag when updating the release (#30984...
authorGiteabot <teabot@gitea.io>
Wed, 15 May 2024 21:34:38 +0000 (05:34 +0800)
committerGitHub <noreply@github.com>
Wed, 15 May 2024 21:34:38 +0000 (16:34 -0500)
We should call `notify_service.NewRelease` when a release is created
from an existing tag.

Co-authored-by: Zettat123 <zettat123@gmail.com>
services/release/release.go

index ba5fd1dd986ebad8a755b7442c6a27bd0d8a72c1..399fdc79c010d904901b6d5bc812f36fef0de2ed 100644 (file)
@@ -204,7 +204,7 @@ func UpdateRelease(ctx context.Context, doer *user_model.User, gitRepo *git.Repo
        if rel.ID == 0 {
                return errors.New("UpdateRelease only accepts an exist release")
        }
-       isCreated, err := createTag(gitRepo.Ctx, gitRepo, rel, "")
+       isTagCreated, err := createTag(gitRepo.Ctx, gitRepo, rel, "")
        if err != nil {
                return err
        }
@@ -216,6 +216,12 @@ func UpdateRelease(ctx context.Context, doer *user_model.User, gitRepo *git.Repo
        }
        defer committer.Close()
 
+       oldRelease, err := repo_model.GetReleaseByID(ctx, rel.ID)
+       if err != nil {
+               return err
+       }
+       isConvertedFromTag := oldRelease.IsTag && !rel.IsTag
+
        if err = repo_model.UpdateRelease(ctx, rel); err != nil {
                return err
        }
@@ -292,7 +298,7 @@ func UpdateRelease(ctx context.Context, doer *user_model.User, gitRepo *git.Repo
        }
 
        if !rel.IsDraft {
-               if !isCreated {
+               if !isTagCreated && !isConvertedFromTag {
                        notify_service.UpdateRelease(gitRepo.Ctx, doer, rel)
                        return nil
                }