mirror of
https://github.com/Jguer/yay.git
synced 2025-12-27 07:35:48 -05:00
chore(ci): update golangci lint v2.1.5 (#2615)
* chore(ci): update golangci-lint to v2.1.5 in ci.Dockerfile * add golangci * fix lint * fix lint pkg/upgrade * reenable lint
This commit is contained in:
@@ -10,6 +10,9 @@ RUN echo "docker ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/docker
|
|||||||
# Create a non-root user and switch to it
|
# Create a non-root user and switch to it
|
||||||
USER docker
|
USER docker
|
||||||
|
|
||||||
|
# Add /app/bin to the PATH
|
||||||
|
ENV PATH="/app/bin:$PATH"
|
||||||
|
|
||||||
# Set the working directory
|
# Set the working directory
|
||||||
WORKDIR /workspace
|
WORKDIR /workspace
|
||||||
|
|
||||||
|
|||||||
8
.github/workflows/testing.yml
vendored
8
.github/workflows/testing.yml
vendored
@@ -16,10 +16,10 @@ jobs:
|
|||||||
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
|
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
|
||||||
restore-keys: |
|
restore-keys: |
|
||||||
${{ runner.os }}-go-
|
${{ runner.os }}-go-
|
||||||
# - name: Lint
|
- name: Lint
|
||||||
# env:
|
env:
|
||||||
# GOFLAGS: -buildvcs=false -tags=next
|
GOFLAGS: -buildvcs=false -tags=next
|
||||||
# run: /app/bin/golangci-lint run -v ./...
|
run: /app/bin/golangci-lint run -v ./...
|
||||||
- name: Run Build and Tests
|
- name: Run Build and Tests
|
||||||
run: make test
|
run: make test
|
||||||
- name: Run Integration Tests
|
- name: Run Integration Tests
|
||||||
|
|||||||
155
.golangci.yml
155
.golangci.yml
@@ -1,67 +1,18 @@
|
|||||||
linters-settings:
|
version: "2"
|
||||||
dupl:
|
run:
|
||||||
threshold: 100
|
go: "1.20"
|
||||||
funlen:
|
|
||||||
lines: 100
|
|
||||||
statements: 50
|
|
||||||
goconst:
|
|
||||||
min-len: 3
|
|
||||||
min-occurrences: 4
|
|
||||||
gocritic:
|
|
||||||
enabled-tags:
|
|
||||||
- diagnostic
|
|
||||||
- experimental
|
|
||||||
- opinionated
|
|
||||||
- performance
|
|
||||||
- style
|
|
||||||
gocyclo:
|
|
||||||
min-complexity: 15
|
|
||||||
goimports:
|
|
||||||
local-prefixes: github.com/Jguer/yay/v12
|
|
||||||
gomnd:
|
|
||||||
checks:
|
|
||||||
- argument
|
|
||||||
- case
|
|
||||||
- condition
|
|
||||||
- return
|
|
||||||
ignored-numbers:
|
|
||||||
- "0"
|
|
||||||
- "1"
|
|
||||||
- "2"
|
|
||||||
- "3"
|
|
||||||
ignored-functions:
|
|
||||||
- strings.SplitN
|
|
||||||
lll:
|
|
||||||
line-length: 140
|
|
||||||
misspell:
|
|
||||||
locale: US
|
|
||||||
nolintlint:
|
|
||||||
allow-unused: false # report any unused nolint directives
|
|
||||||
require-explanation: false # don't require an explanation for nolint directives
|
|
||||||
require-specific: false # don't require nolint directives to be specific about which linter is being skipped
|
|
||||||
|
|
||||||
linters:
|
linters:
|
||||||
# please, do not use `enable-all`: it's deprecated and will be removed soon.
|
default: none
|
||||||
# inverted configuration with `enable-all` and `disable` is not scalable during updates of golangci-lint
|
|
||||||
disable-all: true
|
|
||||||
enable:
|
enable:
|
||||||
- forbidigo
|
|
||||||
- bodyclose
|
- bodyclose
|
||||||
- dogsled
|
- dogsled
|
||||||
- dupl
|
- dupl
|
||||||
- errorlint
|
|
||||||
- errcheck
|
- errcheck
|
||||||
# - funlen # TOFIX
|
- errorlint
|
||||||
- gochecknoinits
|
- gochecknoinits
|
||||||
# - goconst # TOFIX
|
|
||||||
- gocritic
|
- gocritic
|
||||||
# - gocyclo # TOFIX
|
|
||||||
- gofmt
|
|
||||||
- goimports
|
|
||||||
# - gomnd # TOFIX
|
|
||||||
- goprintffuncname
|
- goprintffuncname
|
||||||
- gosec
|
- gosec
|
||||||
- gosimple
|
|
||||||
- govet
|
- govet
|
||||||
- ineffassign
|
- ineffassign
|
||||||
- lll
|
- lll
|
||||||
@@ -70,36 +21,74 @@ linters:
|
|||||||
- noctx
|
- noctx
|
||||||
- nolintlint
|
- nolintlint
|
||||||
- staticcheck
|
- staticcheck
|
||||||
- stylecheck
|
|
||||||
- typecheck
|
|
||||||
- unconvert
|
- unconvert
|
||||||
- unparam
|
- unparam
|
||||||
- unused
|
- unused
|
||||||
- whitespace
|
- whitespace
|
||||||
|
settings:
|
||||||
run:
|
dupl:
|
||||||
go: "1.20"
|
threshold: 100
|
||||||
timeout: "10m"
|
funlen:
|
||||||
forbidigo:
|
lines: 100
|
||||||
forbid:
|
statements: 50
|
||||||
- p: ^fmt\.Print.*$
|
goconst:
|
||||||
msg: Do not commit print statements.
|
min-len: 3
|
||||||
|
min-occurrences: 4
|
||||||
issues:
|
gocritic:
|
||||||
exclude-rules:
|
enabled-tags:
|
||||||
- path: (.+)_test.go
|
- diagnostic
|
||||||
linters:
|
- experimental
|
||||||
- lll
|
- opinionated
|
||||||
- revive
|
- performance
|
||||||
- wsl
|
- style
|
||||||
- govet
|
gocyclo:
|
||||||
- godot
|
min-complexity: 15
|
||||||
- errcheck
|
lll:
|
||||||
- stylecheck
|
line-length: 140
|
||||||
- dupl
|
misspell:
|
||||||
- gocritic
|
locale: US
|
||||||
- gochecknoinits
|
nolintlint:
|
||||||
- errorlint
|
require-explanation: false
|
||||||
|
require-specific: false
|
||||||
exclude:
|
allow-unused: false
|
||||||
- G204
|
exclusions:
|
||||||
|
generated: lax
|
||||||
|
presets:
|
||||||
|
- comments
|
||||||
|
- common-false-positives
|
||||||
|
- legacy
|
||||||
|
- std-error-handling
|
||||||
|
rules:
|
||||||
|
- linters:
|
||||||
|
- dupl
|
||||||
|
- errcheck
|
||||||
|
- errorlint
|
||||||
|
- gochecknoinits
|
||||||
|
- gocritic
|
||||||
|
- godot
|
||||||
|
- govet
|
||||||
|
- lll
|
||||||
|
- revive
|
||||||
|
- staticcheck
|
||||||
|
- wsl
|
||||||
|
path: (.+)_test.go
|
||||||
|
- path: (.+)\.go$
|
||||||
|
text: G204
|
||||||
|
paths:
|
||||||
|
- third_party$
|
||||||
|
- builtin$
|
||||||
|
- examples$
|
||||||
|
formatters:
|
||||||
|
enable:
|
||||||
|
- gofmt
|
||||||
|
- goimports
|
||||||
|
settings:
|
||||||
|
goimports:
|
||||||
|
local-prefixes:
|
||||||
|
- github.com/Jguer/yay/v12
|
||||||
|
exclusions:
|
||||||
|
generated: lax
|
||||||
|
paths:
|
||||||
|
- third_party$
|
||||||
|
- builtin$
|
||||||
|
- examples$
|
||||||
|
|||||||
7
.vscode/settings.json
vendored
Normal file
7
.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"go.lintTool": "golangci-lint",
|
||||||
|
"gopls": {
|
||||||
|
"formatting.gofumpt": true,
|
||||||
|
"formatting.local": "github.com/Jguer/yay/v12"
|
||||||
|
}
|
||||||
|
}
|
||||||
5
clean.go
5
clean.go
@@ -55,9 +55,10 @@ func syncClean(ctx context.Context, run *runtime.Runtime, cmdArgs *parser.Argume
|
|||||||
_, removeAll, _ := cmdArgs.GetArg("c", "clean")
|
_, removeAll, _ := cmdArgs.GetArg("c", "clean")
|
||||||
|
|
||||||
for _, v := range run.PacmanConf.CleanMethod {
|
for _, v := range run.PacmanConf.CleanMethod {
|
||||||
if v == "KeepInstalled" {
|
switch v {
|
||||||
|
case "KeepInstalled":
|
||||||
keepInstalled = true
|
keepInstalled = true
|
||||||
} else if v == "KeepCurrent" {
|
case "KeepCurrent":
|
||||||
keepCurrent = true
|
keepCurrent = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ func srcinfoExists(ctx context.Context,
|
|||||||
return fmt.Errorf("unable to generate .SRCINFO: %w - %s", err, stderr)
|
return fmt.Errorf("unable to generate .SRCINFO: %w - %s", err, stderr)
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(srcinfo) == 0 {
|
if srcinfo == "" {
|
||||||
return fmt.Errorf("generated .SRCINFO is empty, check your PKGBUILD for errors")
|
return fmt.Errorf("generated .SRCINFO is empty, check your PKGBUILD for errors")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ func (i *InstallInfo) String() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type (
|
type (
|
||||||
Reason int
|
Reason uint
|
||||||
Source int
|
Source int
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -804,17 +804,17 @@ func makeAURPKGFromSrcinfo(dbExecutor db.Executor, srcInfo *gosrc.Srcinfo) ([]*a
|
|||||||
Description: getDesc(pkg),
|
Description: getDesc(pkg),
|
||||||
URL: pkg.URL,
|
URL: pkg.URL,
|
||||||
Depends: append(archStringToString(alpmArch, pkg.Depends),
|
Depends: append(archStringToString(alpmArch, pkg.Depends),
|
||||||
archStringToString(alpmArch, srcInfo.Package.Depends)...),
|
archStringToString(alpmArch, srcInfo.Depends)...),
|
||||||
MakeDepends: archStringToString(alpmArch, srcInfo.PackageBase.MakeDepends),
|
MakeDepends: archStringToString(alpmArch, srcInfo.MakeDepends),
|
||||||
CheckDepends: archStringToString(alpmArch, srcInfo.PackageBase.CheckDepends),
|
CheckDepends: archStringToString(alpmArch, srcInfo.CheckDepends),
|
||||||
Conflicts: append(archStringToString(alpmArch, pkg.Conflicts),
|
Conflicts: append(archStringToString(alpmArch, pkg.Conflicts),
|
||||||
archStringToString(alpmArch, srcInfo.Package.Conflicts)...),
|
archStringToString(alpmArch, srcInfo.Conflicts)...),
|
||||||
Provides: append(archStringToString(alpmArch, pkg.Provides),
|
Provides: append(archStringToString(alpmArch, pkg.Provides),
|
||||||
archStringToString(alpmArch, srcInfo.Package.Provides)...),
|
archStringToString(alpmArch, srcInfo.Provides)...),
|
||||||
Replaces: append(archStringToString(alpmArch, pkg.Replaces),
|
Replaces: append(archStringToString(alpmArch, pkg.Replaces),
|
||||||
archStringToString(alpmArch, srcInfo.Package.Replaces)...),
|
archStringToString(alpmArch, srcInfo.Replaces)...),
|
||||||
OptDepends: append(archStringToString(alpmArch, pkg.OptDepends),
|
OptDepends: append(archStringToString(alpmArch, pkg.OptDepends),
|
||||||
archStringToString(alpmArch, srcInfo.Package.OptDepends)...),
|
archStringToString(alpmArch, srcInfo.OptDepends)...),
|
||||||
Groups: pkg.Groups,
|
Groups: pkg.Groups,
|
||||||
License: pkg.License,
|
License: pkg.License,
|
||||||
Keywords: []string{},
|
Keywords: []string{},
|
||||||
|
|||||||
@@ -17,10 +17,10 @@ type IntRange struct {
|
|||||||
// IntRanges is a slice of IntRange.
|
// IntRanges is a slice of IntRange.
|
||||||
type IntRanges []IntRange
|
type IntRanges []IntRange
|
||||||
|
|
||||||
func makeIntRange(min, max int) IntRange {
|
func makeIntRange(minVal, maxVal int) IntRange {
|
||||||
return IntRange{
|
return IntRange{
|
||||||
min,
|
min: minVal,
|
||||||
max,
|
max: maxVal,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -64,9 +64,9 @@ func TestParseNumberMenu(t *testing.T) {
|
|||||||
},
|
},
|
||||||
mapset.NewThreadUnsafeSet[string](), mapset.NewThreadUnsafeSet[string](),
|
mapset.NewThreadUnsafeSet[string](), mapset.NewThreadUnsafeSet[string](),
|
||||||
},
|
},
|
||||||
{IntRanges{}, IntRanges{}, mapset.NewThreadUnsafeSet[string]("abort", "all", "none"), mapset.NewThreadUnsafeSet[string]()},
|
{IntRanges{}, IntRanges{}, mapset.NewThreadUnsafeSet("abort", "all", "none"), mapset.NewThreadUnsafeSet[string]()},
|
||||||
{IntRanges{}, IntRanges{}, mapset.NewThreadUnsafeSet[string]("a-b"), mapset.NewThreadUnsafeSet[string]("abort", "a-b")},
|
{IntRanges{}, IntRanges{}, mapset.NewThreadUnsafeSet("a-b"), mapset.NewThreadUnsafeSet("abort", "a-b")},
|
||||||
{IntRanges{}, IntRanges{}, mapset.NewThreadUnsafeSet[string]("-9223372036854775809-9223372036854775809"), mapset.NewThreadUnsafeSet[string]()},
|
{IntRanges{}, IntRanges{}, mapset.NewThreadUnsafeSet("-9223372036854775809-9223372036854775809"), mapset.NewThreadUnsafeSet[string]()},
|
||||||
{IntRanges{
|
{IntRanges{
|
||||||
makeIntRange(1, 1),
|
makeIntRange(1, 1),
|
||||||
makeIntRange(2, 2),
|
makeIntRange(2, 2),
|
||||||
@@ -86,7 +86,7 @@ func TestParseNumberMenu(t *testing.T) {
|
|||||||
}, IntRanges{}, mapset.NewThreadUnsafeSet[string](), mapset.NewThreadUnsafeSet[string]()},
|
}, IntRanges{}, mapset.NewThreadUnsafeSet[string](), mapset.NewThreadUnsafeSet[string]()},
|
||||||
{IntRanges{}, IntRanges{}, mapset.NewThreadUnsafeSet[string](), mapset.NewThreadUnsafeSet[string]()},
|
{IntRanges{}, IntRanges{}, mapset.NewThreadUnsafeSet[string](), mapset.NewThreadUnsafeSet[string]()},
|
||||||
{IntRanges{}, IntRanges{}, mapset.NewThreadUnsafeSet[string](), mapset.NewThreadUnsafeSet[string]()},
|
{IntRanges{}, IntRanges{}, mapset.NewThreadUnsafeSet[string](), mapset.NewThreadUnsafeSet[string]()},
|
||||||
{IntRanges{}, IntRanges{}, mapset.NewThreadUnsafeSet[string]("a", "b", "c", "d", "e"), mapset.NewThreadUnsafeSet[string]()},
|
{IntRanges{}, IntRanges{}, mapset.NewThreadUnsafeSet("a", "b", "c", "d", "e"), mapset.NewThreadUnsafeSet[string]()},
|
||||||
}
|
}
|
||||||
|
|
||||||
for n, in := range inputs {
|
for n, in := range inputs {
|
||||||
|
|||||||
@@ -289,7 +289,7 @@ func matchesSearch(pkg *aur.Pkg, terms []string) bool {
|
|||||||
desc := strings.ToLower(pkg.Description)
|
desc := strings.ToLower(pkg.Description)
|
||||||
targ := strings.ToLower(pkgN)
|
targ := strings.ToLower(pkgN)
|
||||||
|
|
||||||
if !(strings.Contains(name, targ) || strings.Contains(desc, targ)) {
|
if !strings.Contains(name, targ) && !strings.Contains(desc, targ) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ func GetVersionDiff(oldVersion, newVersion string) (left, right string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for index, char := range oldVersion {
|
for index, char := range oldVersion {
|
||||||
charIsSpecial := !(unicode.IsLetter(char) || unicode.IsNumber(char))
|
charIsSpecial := !unicode.IsLetter(char) && !unicode.IsNumber(char)
|
||||||
|
|
||||||
if (index >= len(newVersion)) || (char != rune(newVersion[index])) {
|
if (index >= len(newVersion)) || (char != rune(newVersion[index])) {
|
||||||
if charIsSpecial {
|
if charIsSpecial {
|
||||||
|
|||||||
@@ -173,11 +173,12 @@ func (c *CmdBuilder) deElevateCommand(ctx context.Context, cmd *exec.Cmd) *exec.
|
|||||||
|
|
||||||
if userFound, err := user.Lookup(ogCaller); err == nil {
|
if userFound, err := user.Lookup(ogCaller); err == nil {
|
||||||
cmd.SysProcAttr = &syscall.SysProcAttr{}
|
cmd.SysProcAttr = &syscall.SysProcAttr{}
|
||||||
uid, _ := strconv.Atoi(userFound.Uid)
|
uid64, errUid := strconv.ParseUint(userFound.Uid, 10, 32)
|
||||||
gid, _ := strconv.Atoi(userFound.Gid)
|
gid64, errGid := strconv.ParseUint(userFound.Gid, 10, 32)
|
||||||
cmd.SysProcAttr.Credential = &syscall.Credential{Uid: uint32(uid), Gid: uint32(gid)}
|
if errUid == nil && errGid == nil {
|
||||||
|
cmd.SysProcAttr.Credential = &syscall.Credential{Uid: uint32(uid64), Gid: uint32(gid64)}
|
||||||
return cmd
|
return cmd
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cmdArgs := []string{
|
cmdArgs := []string{
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ func (o *Option) Add(args ...string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (o *Option) First() string {
|
func (o *Option) First() string {
|
||||||
if o.Args == nil || len(o.Args) == 0 {
|
if len(o.Args) == 0 {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -565,7 +565,6 @@ func (a *Arguments) parseShortOption(arg, param string) (usedNext bool, err erro
|
|||||||
break
|
break
|
||||||
} else {
|
} else {
|
||||||
err = a.AddArg(char)
|
err = a.AddArg(char)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,9 +6,10 @@ import (
|
|||||||
"os/exec"
|
"os/exec"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/Jguer/yay/v12/pkg/settings/exe"
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
|
"github.com/Jguer/yay/v12/pkg/settings/exe"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestParsePackageList(t *testing.T) {
|
func TestParsePackageList(t *testing.T) {
|
||||||
|
|||||||
@@ -194,14 +194,15 @@ func (preper *Preparer) PrepareWorkspace(ctx context.Context,
|
|||||||
|
|
||||||
for _, layer := range targets {
|
for _, layer := range targets {
|
||||||
for _, info := range layer {
|
for _, info := range layer {
|
||||||
if info.Source == dep.AUR {
|
switch info.Source {
|
||||||
|
case dep.AUR:
|
||||||
pkgBase := *info.AURBase
|
pkgBase := *info.AURBase
|
||||||
pkgBuildDir := filepath.Join(preper.cfg.BuildDir, pkgBase)
|
pkgBuildDir := filepath.Join(preper.cfg.BuildDir, pkgBase)
|
||||||
if preper.needToCloneAURBase(info, pkgBuildDir) {
|
if preper.needToCloneAURBase(info, pkgBuildDir) {
|
||||||
aurBasesToClone.Add(pkgBase)
|
aurBasesToClone.Add(pkgBase)
|
||||||
}
|
}
|
||||||
pkgBuildDirsByBase[pkgBase] = pkgBuildDir
|
pkgBuildDirsByBase[pkgBase] = pkgBuildDir
|
||||||
} else if info.Source == dep.SrcInfo {
|
case dep.SrcInfo:
|
||||||
pkgBase := *info.AURBase
|
pkgBase := *info.AURBase
|
||||||
pkgBuildDirsByBase[pkgBase] = *info.SrcinfoPath
|
pkgBuildDirsByBase[pkgBase] = *info.SrcinfoPath
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,12 +23,12 @@ func SplitDBFromName(pkg string) (db, name string) {
|
|||||||
|
|
||||||
// LessRunes compares two rune values, and returns true if the first argument is lexicographicaly smaller.
|
// LessRunes compares two rune values, and returns true if the first argument is lexicographicaly smaller.
|
||||||
func LessRunes(iRunes, jRunes []rune) bool {
|
func LessRunes(iRunes, jRunes []rune) bool {
|
||||||
max := len(iRunes)
|
maxLen := len(iRunes)
|
||||||
if max > len(jRunes) {
|
if maxLen > len(jRunes) {
|
||||||
max = len(jRunes)
|
maxLen = len(jRunes)
|
||||||
}
|
}
|
||||||
|
|
||||||
for idx := 0; idx < max; idx++ {
|
for idx := 0; idx < maxLen; idx++ {
|
||||||
ir := iRunes[idx]
|
ir := iRunes[idx]
|
||||||
jr := jRunes[idx]
|
jr := jRunes[idx]
|
||||||
|
|
||||||
|
|||||||
@@ -201,7 +201,8 @@ func (u *UpgradeService) graphToUpSlice(graph *topo.Graph[string, *dep.InstallIn
|
|||||||
extra = fmt.Sprintf(" (%s of %s)", dep.ReasonNames[info.Reason], strings.Join(reducedParents, ", "))
|
extra = fmt.Sprintf(" (%s of %s)", dep.ReasonNames[info.Reason], strings.Join(reducedParents, ", "))
|
||||||
}
|
}
|
||||||
|
|
||||||
if info.Source == dep.AUR {
|
switch info.Source {
|
||||||
|
case dep.AUR:
|
||||||
aurRepo := "aur"
|
aurRepo := "aur"
|
||||||
if info.Devel {
|
if info.Devel {
|
||||||
aurRepo = "devel"
|
aurRepo = "devel"
|
||||||
@@ -215,7 +216,7 @@ func (u *UpgradeService) graphToUpSlice(graph *topo.Graph[string, *dep.InstallIn
|
|||||||
Reason: alpmReason,
|
Reason: alpmReason,
|
||||||
Extra: extra,
|
Extra: extra,
|
||||||
})
|
})
|
||||||
} else if info.Source == dep.Sync {
|
case dep.Sync:
|
||||||
repoUp.Up = append(repoUp.Up, Upgrade{
|
repoUp.Up = append(repoUp.Up, Upgrade{
|
||||||
Name: name,
|
Name: name,
|
||||||
RemoteVersion: info.Version,
|
RemoteVersion: info.Version,
|
||||||
|
|||||||
@@ -38,9 +38,10 @@ func (u UpSlice) Less(i, j int) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, db := range u.Repos {
|
for _, db := range u.Repos {
|
||||||
if db == u.Up[i].Repository {
|
switch db {
|
||||||
|
case u.Up[i].Repository:
|
||||||
return true
|
return true
|
||||||
} else if db == u.Up[j].Repository {
|
case u.Up[j].Repository:
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -52,9 +53,7 @@ func (u UpSlice) Less(i, j int) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// calculateFormatting calculates formatting parameters for printing upgrades
|
// calculateFormatting calculates formatting parameters for printing upgrades
|
||||||
func calculateFormatting(upgrades []Upgrade) (int, int, int) {
|
func calculateFormatting(upgrades []Upgrade) (longestName, longestVersion, longestNumber int) {
|
||||||
longestName, longestVersion := 0, 0
|
|
||||||
|
|
||||||
for i := range upgrades {
|
for i := range upgrades {
|
||||||
upgrade := &upgrades[i]
|
upgrade := &upgrades[i]
|
||||||
packNameLen := len(StylizedNameWithRepository(upgrade))
|
packNameLen := len(StylizedNameWithRepository(upgrade))
|
||||||
@@ -65,9 +64,9 @@ func calculateFormatting(upgrades []Upgrade) (int, int, int) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
lenUp := len(upgrades)
|
lenUp := len(upgrades)
|
||||||
longestNumber := len(fmt.Sprintf("%v", lenUp))
|
longestNumber = len(fmt.Sprintf("%v", lenUp))
|
||||||
|
|
||||||
return longestName, longestVersion, longestNumber
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Print prints the details of the packages to upgrade.
|
// Print prints the details of the packages to upgrade.
|
||||||
|
|||||||
Reference in New Issue
Block a user