From ca8681f9972961c218df60fd2f4c01cee48d56b0 Mon Sep 17 00:00:00 2001 From: Grzegorz Dlugoszewski Date: Sun, 24 Aug 2025 18:28:09 +0200 Subject: [PATCH] Fix issues found by nlreturn linter --- pkg/git/finder.go | 1 + pkg/git/repo.go | 2 ++ pkg/git/status.go | 1 + pkg/git/test/testrepos.go | 1 + pkg/out/flat.go | 1 + pkg/out/tree.go | 1 + pkg/run/run.go | 1 + 7 files changed, 8 insertions(+) diff --git a/pkg/git/finder.go b/pkg/git/finder.go index 87d4251..cfef9da 100644 --- a/pkg/git/finder.go +++ b/pkg/git/finder.go @@ -85,6 +85,7 @@ func (f *RepoFinder) Find() error { gitPath := filepath.Join(path, dotgit) if _, err := os.Stat(gitPath); err == nil { f.addIfOk(path) + return fs.SkipDir // Skip this directory's contents since it's a repo } diff --git a/pkg/git/repo.go b/pkg/git/repo.go index 201d31d..8095481 100644 --- a/pkg/git/repo.go +++ b/pkg/git/repo.go @@ -57,6 +57,7 @@ func Clone(opts *CloneOpts) (*Repo, error) { if err != nil { cleanupFailedClone(opts.Path) + return nil, err } @@ -68,6 +69,7 @@ func Clone(opts *CloneOpts) (*Repo, error) { // Fetch preforms a git fetch on all remotes. func (r *Repo) Fetch() error { err := run.Git("fetch", "--all").OnRepo(r.path).AndShutUp() + return err } diff --git a/pkg/git/status.go b/pkg/git/status.go index 18b2ac3..7c644d1 100644 --- a/pkg/git/status.go +++ b/pkg/git/status.go @@ -65,6 +65,7 @@ func (r *Repo) loadBranches() (map[string]string, []error) { branches, err := r.Branches() if err != nil { errors = append(errors, err) + return statuses, errors } diff --git a/pkg/git/test/testrepos.go b/pkg/git/test/testrepos.go index c25434c..6dd0ce1 100644 --- a/pkg/git/test/testrepos.go +++ b/pkg/git/test/testrepos.go @@ -20,6 +20,7 @@ func (r *Repo) Path() string { // RepoEmpty creates an empty git repo. func RepoEmpty(t *testing.T) *Repo { t.Helper() + return RepoEmptyInDir(t, "") } diff --git a/pkg/out/flat.go b/pkg/out/flat.go index 0edcf3d..be9d1a4 100644 --- a/pkg/out/flat.go +++ b/pkg/out/flat.go @@ -23,6 +23,7 @@ func (p *FlatPrinter) Print(repos []Printable) string { if len(repo.Errors()) > 0 { str.WriteString(" " + red("error") + "\n") + continue } diff --git a/pkg/out/tree.go b/pkg/out/tree.go index 8bbe097..b046a68 100644 --- a/pkg/out/tree.go +++ b/pkg/out/tree.go @@ -216,6 +216,7 @@ func (n *Node) isYoungest() bool { for i, sis := range sisters { if sis.val == n.val { myIndex = i + break } } diff --git a/pkg/run/run.go b/pkg/run/run.go index 4c104c8..a84fdcd 100644 --- a/pkg/run/run.go +++ b/pkg/run/run.go @@ -133,5 +133,6 @@ func (e GitError) Error() string { func lines(output []byte) []string { lines := strings.TrimSuffix(string(output), "\n") + return strings.Split(lines, "\n") }