From c70adbd0ec370993490c19dccdec60b9bfc2d9dd Mon Sep 17 00:00:00 2001 From: mkelvers Date: Thu, 11 Jun 2026 12:06:04 +0200 Subject: [PATCH] fix: only report new lint issues with --new-from-rev --- integrations/playback/allanime/client.go | 20 ++++++++++---------- lefthook.yml | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/integrations/playback/allanime/client.go b/integrations/playback/allanime/client.go index 6d39bce..5d5995f 100644 --- a/integrations/playback/allanime/client.go +++ b/integrations/playback/allanime/client.go @@ -295,13 +295,13 @@ func (c *AllAnimeProvider) graphqlRequest(ctx context.Context, query string, var req.Header.Set("Referer", allAnimeReferer) req.Header.Set("User-Agent", defaultUserAgent) - resp, respBody, err := executeAndReadResponse(c.httpClient, req, "execute graphql request", "read graphql response") + statusCode, respBody, err := executeAndReadResponse(c.httpClient, req, "execute graphql request", "read graphql response") if err != nil { return nil, err } - if resp.StatusCode != http.StatusOK { - return nil, fmt.Errorf("graphql status %d", resp.StatusCode) + if statusCode != http.StatusOK { + return nil, fmt.Errorf("graphql status %d", statusCode) } var parsed map[string]any @@ -344,13 +344,13 @@ func (c *AllAnimeProvider) graphqlRequestWithHash(ctx context.Context, showID, e req.Header.Set("Sec-Fetch-Mode", "cors") req.Header.Set("Sec-Fetch-Site", "cross-site") - resp, respBody, err := executeAndReadResponse(c.utlsClient, req, "execute GET request", "read response") + statusCode, respBody, err := executeAndReadResponse(c.utlsClient, req, "execute GET request", "read response") if err != nil { return nil, err } - if resp.StatusCode != http.StatusOK { - return nil, fmt.Errorf("GET status %d: %s", resp.StatusCode, string(respBody)) + if statusCode != http.StatusOK { + return nil, fmt.Errorf("GET status %d: %s", statusCode, string(respBody)) } var parsed map[string]any @@ -535,19 +535,19 @@ func (c *AllAnimeProvider) resolveSourceReferences(ctx context.Context, referenc return out } -func executeAndReadResponse(client *http.Client, req *http.Request, executeErrPrefix string, readErrPrefix string) (*http.Response, []byte, error) { +func executeAndReadResponse(client *http.Client, req *http.Request, executeErrPrefix string, readErrPrefix string) (int, []byte, error) { resp, err := client.Do(req) if err != nil { - return nil, nil, fmt.Errorf("%s: %w", executeErrPrefix, err) + return 0, nil, fmt.Errorf("%s: %w", executeErrPrefix, err) } defer func() { _ = resp.Body.Close() }() body, err := io.ReadAll(io.LimitReader(resp.Body, netutil.MiB2)) if err != nil { - return nil, nil, fmt.Errorf("%s: %w", readErrPrefix, err) + return 0, nil, fmt.Errorf("%s: %w", readErrPrefix, err) } - return resp, body, nil + return resp.StatusCode, body, nil } func buildStreamSource(url, sourceType, provider string) StreamSource { diff --git a/lefthook.yml b/lefthook.yml index e78f028..a267b33 100644 --- a/lefthook.yml +++ b/lefthook.yml @@ -20,7 +20,7 @@ { "glob": "*.go", "run": - 'printf "%s\n" {staged_files} | xargs -n1 dirname | sort -u | xargs -I{} golangci-lint run ./{}', + 'printf "%s\n" {staged_files} | xargs -n1 dirname | sort -u | xargs -I{} golangci-lint run --new-from-rev=HEAD ./{}', }, "go-test": {