mirror of
https://github.com/grdl/git-get.git
synced 2026-02-04 11:01:46 +00:00
Fix smaller issues found by various linters
This commit is contained in:
@@ -105,13 +105,13 @@ func (f *RepoFinder) Find() error {
|
||||
// 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.
|
||||
func (f *RepoFinder) LoadAll(fetch bool) []*Status {
|
||||
var statuses []*Status
|
||||
statuses := []*Status{}
|
||||
|
||||
reposChan := make(chan *Repo, f.maxWorkers)
|
||||
statusChan := make(chan *Status, f.maxWorkers)
|
||||
|
||||
// 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)
|
||||
}
|
||||
|
||||
|
||||
@@ -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()
|
||||
if err != nil {
|
||||
// TODO: no upstream will also throw an error.
|
||||
// lint:ignore nilerr fix when working on TODO
|
||||
return "", nil
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ type Printable interface {
|
||||
Path() string
|
||||
Current() string
|
||||
Branches() []string
|
||||
BranchStatus(string) string
|
||||
BranchStatus(branch string) string
|
||||
WorkTreeStatus() string
|
||||
Remote() string
|
||||
Errors() []string
|
||||
|
||||
@@ -3,6 +3,7 @@ package run
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
@@ -32,8 +33,9 @@ type Cmd struct {
|
||||
|
||||
// Git creates a git command with given arguments.
|
||||
func Git(args ...string) *Cmd {
|
||||
ctx := context.Background()
|
||||
return &Cmd{
|
||||
cmd: exec.Command("git", args...),
|
||||
cmd: exec.CommandContext(ctx, "git", args...),
|
||||
args: strings.Join(args, " "),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@ var scpSyntax = regexp.MustCompile(`^([a-zA-Z0-9_]+)@([a-zA-Z0-9._-]+):(.*)$`)
|
||||
// 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 scheme, use the defaultScheme.
|
||||
func ParseURL(rawURL string, defaultHost string, defaultScheme string) (url *urlpkg.URL, err error) {
|
||||
url, err = parseRawURL(rawURL)
|
||||
func ParseURL(rawURL string, defaultHost string, defaultScheme string) (*urlpkg.URL, error) {
|
||||
url, err := parseRawURL(rawURL)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user