6
0
mirror of https://github.com/grdl/git-get.git synced 2026-02-12 23:25:15 +00:00

Fix smaller issues found by various linters

This commit is contained in:
Grzegorz Dlugoszewski
2025-08-24 17:51:14 +02:00
parent b39f5e63fd
commit 2de126166f
5 changed files with 9 additions and 6 deletions

View File

@@ -105,13 +105,13 @@ func (f *RepoFinder) Find() error {
// If fetch equals true, it first fetches from the remote repo before loading the status. // If fetch equals true, it first fetches from the remote repo before loading the status.
// Each repo is loaded concurrently by a separate worker, with max 100 workers being active at the same time. // Each repo is loaded concurrently by a separate worker, with max 100 workers being active at the same time.
func (f *RepoFinder) LoadAll(fetch bool) []*Status { func (f *RepoFinder) LoadAll(fetch bool) []*Status {
var statuses []*Status statuses := []*Status{}
reposChan := make(chan *Repo, f.maxWorkers) reposChan := make(chan *Repo, f.maxWorkers)
statusChan := make(chan *Status, f.maxWorkers) statusChan := make(chan *Status, f.maxWorkers)
// Fire up workers. They listen on reposChan, load status and send the result to statusChan. // Fire up workers. They listen on reposChan, load status and send the result to statusChan.
for i := 0; i < f.maxWorkers; i++ { for range f.maxWorkers {
go statusWorker(fetch, reposChan, statusChan) go statusWorker(fetch, reposChan, statusChan)
} }

View File

@@ -156,6 +156,7 @@ func (r *Repo) Upstream(branch string) (string, error) {
out, err := run.Git("rev-parse", "--abbrev-ref", "--symbolic-full-name", fmt.Sprintf("%s@{upstream}", branch)).OnRepo(r.path).AndCaptureLine() out, err := run.Git("rev-parse", "--abbrev-ref", "--symbolic-full-name", fmt.Sprintf("%s@{upstream}", branch)).OnRepo(r.path).AndCaptureLine()
if err != nil { if err != nil {
// TODO: no upstream will also throw an error. // TODO: no upstream will also throw an error.
// lint:ignore nilerr fix when working on TODO
return "", nil return "", nil
} }

View File

@@ -15,7 +15,7 @@ type Printable interface {
Path() string Path() string
Current() string Current() string
Branches() []string Branches() []string
BranchStatus(string) string BranchStatus(branch string) string
WorkTreeStatus() string WorkTreeStatus() string
Remote() string Remote() string
Errors() []string Errors() []string

View File

@@ -3,6 +3,7 @@ package run
import ( import (
"bytes" "bytes"
"context"
"fmt" "fmt"
"os" "os"
"os/exec" "os/exec"
@@ -32,8 +33,9 @@ type Cmd struct {
// Git creates a git command with given arguments. // Git creates a git command with given arguments.
func Git(args ...string) *Cmd { func Git(args ...string) *Cmd {
ctx := context.Background()
return &Cmd{ return &Cmd{
cmd: exec.Command("git", args...), cmd: exec.CommandContext(ctx, "git", args...),
args: strings.Join(args, " "), args: strings.Join(args, " "),
} }
} }

View File

@@ -19,8 +19,8 @@ var scpSyntax = regexp.MustCompile(`^([a-zA-Z0-9_]+)@([a-zA-Z0-9._-]+):(.*)$`)
// ParseURL parses given rawURL string into a URL. // ParseURL parses given rawURL string into a URL.
// When the parsed URL has an empty host, use the defaultHost. // When the parsed URL has an empty host, use the defaultHost.
// When the parsed URL has an empty scheme, use the defaultScheme. // When the parsed URL has an empty scheme, use the defaultScheme.
func ParseURL(rawURL string, defaultHost string, defaultScheme string) (url *urlpkg.URL, err error) { func ParseURL(rawURL string, defaultHost string, defaultScheme string) (*urlpkg.URL, error) {
url, err = parseRawURL(rawURL) url, err := parseRawURL(rawURL)
if err != nil { if err != nil {
return nil, err return nil, err
} }