code.gitea.io/gitea@v1.21.7/services/convert/release.go (about) 1 // Copyright 2020 The Gitea Authors. All rights reserved. 2 // SPDX-License-Identifier: MIT 3 4 package convert 5 6 import ( 7 "context" 8 9 repo_model "code.gitea.io/gitea/models/repo" 10 api "code.gitea.io/gitea/modules/structs" 11 ) 12 13 // ToAPIRelease convert a repo_model.Release to api.Release 14 func ToAPIRelease(ctx context.Context, repo *repo_model.Repository, r *repo_model.Release) *api.Release { 15 return &api.Release{ 16 ID: r.ID, 17 TagName: r.TagName, 18 Target: r.Target, 19 Title: r.Title, 20 Note: r.Note, 21 URL: r.APIURL(), 22 HTMLURL: r.HTMLURL(), 23 TarURL: r.TarURL(), 24 ZipURL: r.ZipURL(), 25 UploadURL: r.APIUploadURL(), 26 IsDraft: r.IsDraft, 27 IsPrerelease: r.IsPrerelease, 28 CreatedAt: r.CreatedUnix.AsTime(), 29 PublishedAt: r.CreatedUnix.AsTime(), 30 Publisher: ToUser(ctx, r.Publisher, nil), 31 Attachments: ToAPIAttachments(repo, r.Attachments), 32 } 33 }