multiple content per fetcher

This commit is contained in:
2026-01-20 18:10:26 +01:00
parent 4f168197b8
commit 76933a04d8
7 changed files with 129 additions and 99 deletions

View File

@@ -33,41 +33,37 @@ func (f *GiteaFetcher) Fetch() []Entry {
continue
}
path := fmt.Sprintf("/api/v1/repos/%s/commits?limit=1", repo)
headers := map[string]string{}
if f.Token != "" {
headers["Authorization"] = "token " + f.Token
}
req := FetcherRequest{
BaseURL: f.BaseURL,
Path: path,
Path: fmt.Sprintf("/api/v1/repos/%s/commits?limit=%d", repo, f.ContentLimit),
Method: http.MethodGet,
Headers: headers,
Headers: map[string]string{
"Authorization": "token " + f.Token,
},
}
var resp GiteaResponse
if err := req.Run(&resp); err != nil {
var response GiteaResponse
if err := req.Run(&response); err != nil {
continue
}
if len(resp) == 0 {
if len(response) == 0 {
continue
}
commit := resp[0]
cacheKey := "gitea_" + url.QueryEscape(f.BaseURL+path)
for _, content := range response {
cacheKey := "gitea_commit_" + url.QueryEscape(f.BaseURL+repo+"_"+content.Sha)
entry := f.TryCreateEntry(
cacheKey,
commit.Sha,
fmt.Sprintf("📝 [%s] - (%s) %s", f.Name(), repo, commit.Commit.Message),
commit.HTMLURL,
)
entry := f.TryCreateEntry(
cacheKey,
content.Sha,
fmt.Sprintf("📝 [%s] - (%s) %s", f.Name(), repo, content.Commit.Message),
content.HTMLURL,
)
if entry != nil {
entries = append(entries, *entry)
if entry != nil {
entries = append(entries, *entry)
}
}
}