FetcherRequest
This commit is contained in:
@@ -29,15 +29,25 @@ func (f GiteaFetcher) Fetch() []Entry {
|
||||
if repo == "" {
|
||||
continue
|
||||
}
|
||||
giteaURL := fmt.Sprintf("%s/api/v1/repos/%s/commits", f.BaseURL, strings.TrimSpace(repo))
|
||||
req, _ := http.NewRequest("GET", giteaURL, nil)
|
||||
|
||||
repo = strings.TrimSpace(repo)
|
||||
path := fmt.Sprintf("/api/v1/repos/%s/commits", repo)
|
||||
|
||||
headers := map[string]string{}
|
||||
if f.Token != "" {
|
||||
req.Header.Set("Authorization", "token "+f.Token)
|
||||
headers["Authorization"] = "token " + f.Token
|
||||
}
|
||||
|
||||
req := FetcherRequest{
|
||||
BaseURL: f.BaseURL,
|
||||
Path: path,
|
||||
Method: http.MethodGet,
|
||||
Headers: headers,
|
||||
}
|
||||
|
||||
var r GiteaResponse
|
||||
|
||||
if err := getJSON(req, &r); err != nil {
|
||||
if err := req.Run(&r); err != nil {
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -46,8 +56,9 @@ func (f GiteaFetcher) Fetch() []Entry {
|
||||
}
|
||||
|
||||
commit := r[0]
|
||||
cacheKey := "gitea_" + url.QueryEscape(f.BaseURL+path)
|
||||
|
||||
if f.Cache.TryUpdate("gitea_"+url.QueryEscape(giteaURL), commit.Sha) {
|
||||
if f.Cache.TryUpdate(cacheKey, commit.Sha) {
|
||||
messages = append(messages, Entry{
|
||||
Title: fmt.Sprintf("📝 [Gitea] - (%s) %s", repo, commit.Commit.Message),
|
||||
URL: commit.HTMLURL,
|
||||
|
||||
Reference in New Issue
Block a user