Skip to content

Commit

Permalink
PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
kemzeb committed Jan 13, 2025
1 parent 62d47e0 commit 69984e5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion routers/web/repo/release.go
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ func NewReleasePost(ctx *context.Context) {
return
}
} else {
if len(form.TagOnly) > 0 && rel.IsTag {
if form.TagOnly != "" && rel.IsTag {
ctx.Data["Err_TagName"] = true
ctx.RenderWithErr(ctx.Tr("repo.release.tag_name_already_exist"), tplReleaseNew, &form)
return
Expand Down
18 changes: 16 additions & 2 deletions routers/web/repo/release_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,32 @@ func TestNewReleasePost(t *testing.T) {
RepoID int64
UserID int64
TagName string
IsTag bool
Form forms.NewReleaseForm
}{
{
{ // pre-existing tag
RepoID: 1,
UserID: 2,
TagName: "v1.1", // pre-existing tag
TagName: "v1.1",
Form: forms.NewReleaseForm{
TagName: "newtag",
Target: "master",
Title: "title",
Content: "content",
},
},
{ // creating a new tag when there's already a pre-existing tag
RepoID: 1,
UserID: 2,
TagName: "delete-tag",
IsTag: true,
Form: forms.NewReleaseForm{
TagName: "delete-tag",
Target: "master",
Title: "delete-tag",
TagOnly: "1",
},
},
{
RepoID: 1,
UserID: 2,
Expand Down Expand Up @@ -62,6 +75,7 @@ func TestNewReleasePost(t *testing.T) {
Target: testCase.Form.Target,
Title: testCase.Form.Title,
Note: testCase.Form.Content,
IsTag: true,
}, unittest.Cond("is_draft=?", len(testCase.Form.Draft) > 0))
ctx.Repo.GitRepo.Close()
}
Expand Down

0 comments on commit 69984e5

Please sign in to comment.