fix(release): allow publishing drafts without target #35569 (#38800)

### Issue

Fully publishing a draft release fails when the release does not have a
target set.

A draft release can be created without a target because the Git tag is
not created while the release remains a draft. However, when the draft
is published, Gitea attempts to resolve the release target to create the
tag. If the target is empty, the publish operation fails.

### Solution

Use the repository's default branch as the target when a draft release
is published without an explicitly configured target.

Also add a regression test to verify that a draft release without a
target can be successfully published.

Fixes #35569

---------

Signed-off-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
Mitrahsoft
2026-08-07 20:36:16 +05:30
committed by GitHub
parent 9fc5d20006
commit d4333eb043
2 changed files with 3 additions and 2 deletions
+2 -1
View File
@@ -102,7 +102,8 @@ func createTag(ctx context.Context, gitRepo *git.Repository, rel *repo_model.Rel
}
}
commit, err := gitRepo.GetCommit(ctx, rel.Target)
target := util.IfZero(rel.Target, rel.Repo.DefaultBranch)
commit, err := gitRepo.GetCommit(ctx, target)
if err != nil {
return false, err
}
+1 -1
View File
@@ -228,7 +228,7 @@ func TestRelease_Update(t *testing.T) {
PublisherID: user.ID,
Publisher: user,
TagName: "v1.1.2",
Target: "master",
Target: "",
Title: "v1.1.2 is released",
Note: "v1.1.2 is released",
IsDraft: true,