mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-12-01 05:36:19 +01:00
e81ccc406b
Change all license headers to comply with REUSE specification. Fix #16132 Co-authored-by: flynnnnnnnnnn <flynnnnnnnnnn@github> Co-authored-by: John Olheiser <john.olheiser@gmail.com>
47 lines
1.3 KiB
Go
47 lines
1.3 KiB
Go
// Copyright 2020 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package convert
|
|
|
|
import (
|
|
repo_model "code.gitea.io/gitea/models/repo"
|
|
api "code.gitea.io/gitea/modules/structs"
|
|
)
|
|
|
|
// ToRelease convert a repo_model.Release to api.Release
|
|
func ToRelease(r *repo_model.Release) *api.Release {
|
|
assets := make([]*api.Attachment, 0)
|
|
for _, att := range r.Attachments {
|
|
assets = append(assets, ToReleaseAttachment(att))
|
|
}
|
|
return &api.Release{
|
|
ID: r.ID,
|
|
TagName: r.TagName,
|
|
Target: r.Target,
|
|
Title: r.Title,
|
|
Note: r.Note,
|
|
URL: r.APIURL(),
|
|
HTMLURL: r.HTMLURL(),
|
|
TarURL: r.TarURL(),
|
|
ZipURL: r.ZipURL(),
|
|
IsDraft: r.IsDraft,
|
|
IsPrerelease: r.IsPrerelease,
|
|
CreatedAt: r.CreatedUnix.AsTime(),
|
|
PublishedAt: r.CreatedUnix.AsTime(),
|
|
Publisher: ToUser(r.Publisher, nil),
|
|
Attachments: assets,
|
|
}
|
|
}
|
|
|
|
// ToReleaseAttachment converts models.Attachment to api.Attachment
|
|
func ToReleaseAttachment(a *repo_model.Attachment) *api.Attachment {
|
|
return &api.Attachment{
|
|
ID: a.ID,
|
|
Name: a.Name,
|
|
Created: a.CreatedUnix.AsTime(),
|
|
DownloadCount: a.DownloadCount,
|
|
Size: a.Size,
|
|
UUID: a.UUID,
|
|
DownloadURL: a.DownloadURL(),
|
|
}
|
|
}
|