Fix new release creation API to allow empty target (#5870)

* Fix new release creation API to allow empty target

* Add more test cases

* Update swagger
This commit is contained in:
Lauris BH 2019-01-30 18:33:00 +02:00 committed by techknowlogick
parent 8b5f6ced22
commit fada6968a8
11 changed files with 168 additions and 348 deletions

View file

@ -152,6 +152,10 @@ func CreateRelease(ctx *context.APIContext, form api.CreateReleaseOption) {
ctx.ServerError("GetRelease", err)
return
}
// If target is not provided use default branch
if len(form.Target) == 0 {
form.Target = ctx.Repo.Repository.DefaultBranch
}
rel = &models.Release{
RepoID: ctx.Repo.Repository.ID,
PublisherID: ctx.User.ID,