response structs
This commit is contained in:
@@ -7,6 +7,14 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
type GiteaResponse []struct {
|
||||
Sha string `json:"sha"`
|
||||
HTMLURL string `json:"html_url"`
|
||||
Commit struct {
|
||||
Message string `json:"message"`
|
||||
} `json:"commit"`
|
||||
}
|
||||
|
||||
type GiteaFetcher struct {
|
||||
BaseURL string
|
||||
Token string
|
||||
@@ -27,13 +35,8 @@ func (f GiteaFetcher) Fetch() []string {
|
||||
req.Header.Set("Authorization", "token "+f.Token)
|
||||
}
|
||||
|
||||
var r []struct {
|
||||
Sha string `json:"sha"`
|
||||
Commit struct {
|
||||
Message string `json:"message"`
|
||||
} `json:"commit"`
|
||||
HTMLURL string `json:"html_url"`
|
||||
}
|
||||
var r GiteaResponse
|
||||
|
||||
if err := getJSON(req, &r); err != nil {
|
||||
continue
|
||||
}
|
||||
@@ -41,10 +44,11 @@ func (f GiteaFetcher) Fetch() []string {
|
||||
if len(r) == 0 {
|
||||
continue
|
||||
}
|
||||
c := r[0]
|
||||
|
||||
if f.Cache.TryUpdate("gitea_"+url.QueryEscape(giteaURL), c.Sha) {
|
||||
messages = append(messages, fmt.Sprintf("Gitea: %s <%s>", c.Commit.Message, c.HTMLURL))
|
||||
commit := r[0]
|
||||
|
||||
if f.Cache.TryUpdate("gitea_"+url.QueryEscape(giteaURL), commit.Sha) {
|
||||
messages = append(messages, fmt.Sprintf("Gitea: %s <%s>", commit.Commit.Message, commit.HTMLURL))
|
||||
}
|
||||
}
|
||||
return messages
|
||||
|
||||
Reference in New Issue
Block a user