gitea源码

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