From 51805995831a74bd0b58074fb3d3535bec168291 Mon Sep 17 00:00:00 2001 From: Simon Cornet Date: Mon, 7 Jul 2025 22:23:31 +0200 Subject: [PATCH] feat(ci): fix linter complaints --- cmd/gogitlabber/git.go | 9 ++++++--- cmd/gogitlabber/gitea.go | 6 +++++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/cmd/gogitlabber/git.go b/cmd/gogitlabber/git.go index 4043b1d..16280a6 100644 --- a/cmd/gogitlabber/git.go +++ b/cmd/gogitlabber/git.go @@ -274,13 +274,16 @@ func handleResult(result GitOperationResult, stats *GitStats) { logger.Print("Successfully pulled: "+result.RepoName, nil) case "error": - if result.ErrorType == "unstaged" { + switch result.ErrorType { + case "unstaged": stats.IncrementCounter("unstaged", result.RepoName) logger.Print("Found unstaged changes in: "+result.RepoName, nil) - } else if result.ErrorType == "uncommitted" { + + case "uncommitted": stats.IncrementCounter("uncommitted", result.RepoName) logger.Print("Found uncommitted changes in: "+result.RepoName, nil) - } else { + + default: stats.IncrementCounter("error", "") logger.Print("ERROR processing "+result.RepoName+": "+result.Error.Error(), nil) } diff --git a/cmd/gogitlabber/gitea.go b/cmd/gogitlabber/gitea.go index 1604089..9afaea7 100644 --- a/cmd/gogitlabber/gitea.go +++ b/cmd/gogitlabber/gitea.go @@ -213,7 +213,11 @@ func (c *GiteaClient) ValidateConnection(ctx context.Context) error { if err != nil { return fmt.Errorf("making validation request: %w", err) } - defer resp.Body.Close() + defer func() { + if err := resp.Body.Close(); err != nil { + logger.Print("failed to close response body: %v", err) + } + }() if resp.StatusCode == http.StatusUnauthorized { return fmt.Errorf("invalid or expired token")