-
Notifications
You must be signed in to change notification settings - Fork 15
/
gitea_release.go
113 lines (91 loc) · 1.95 KB
/
gitea_release.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
package selfupdate
import (
"time"
"code.gitea.io/sdk/gitea"
)
type GiteaRelease struct {
releaseID int64
name string
tagName string
url string
draft bool
prerelease bool
publishedAt time.Time
releaseNotes string
assets []SourceAsset
}
func NewGiteaRelease(from *gitea.Release) *GiteaRelease {
release := &GiteaRelease{
releaseID: from.ID,
name: from.Title,
tagName: from.TagName,
url: "", //FIXME: we kind of have no url ?
publishedAt: from.PublishedAt,
releaseNotes: from.Note,
draft: from.IsDraft,
prerelease: from.IsPrerelease,
assets: make([]SourceAsset, len(from.Attachments)),
}
for i, fromAsset := range from.Attachments {
release.assets[i] = NewGiteaAsset(fromAsset)
}
return release
}
func (r *GiteaRelease) GetID() int64 {
return r.releaseID
}
func (r *GiteaRelease) GetTagName() string {
return r.tagName
}
func (r *GiteaRelease) GetDraft() bool {
return r.draft
}
func (r *GiteaRelease) GetPrerelease() bool {
return r.prerelease
}
func (r *GiteaRelease) GetPublishedAt() time.Time {
return r.publishedAt
}
func (r *GiteaRelease) GetReleaseNotes() string {
return r.releaseNotes
}
func (r *GiteaRelease) GetName() string {
return r.name
}
func (r *GiteaRelease) GetURL() string {
return r.url
}
func (r *GiteaRelease) GetAssets() []SourceAsset {
return r.assets
}
type GiteaAsset struct {
id int64
name string
size int
url string
}
func NewGiteaAsset(from *gitea.Attachment) *GiteaAsset {
return &GiteaAsset{
id: from.ID,
name: from.Name,
size: int(from.Size),
url: from.DownloadURL,
}
}
func (a *GiteaAsset) GetID() int64 {
return a.id
}
func (a *GiteaAsset) GetName() string {
return a.name
}
func (a *GiteaAsset) GetSize() int {
return a.size
}
func (a *GiteaAsset) GetBrowserDownloadURL() string {
return a.url
}
// Verify interface
var (
_ SourceRelease = &GiteaRelease{}
_ SourceAsset = &GiteaAsset{}
)