mirror of
https://github.com/go-gitea/gitea.git
synced 2026-08-08 15:57:42 +00:00
### 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:
@@ -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
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user