fix(format): gofumt files

This commit is contained in:
jguer 2020-07-08 03:40:50 +02:00
parent a0cff2b622
commit e47c9584c1
No known key found for this signature in database
GPG Key ID: 6D6CC9BEA8556B35
11 changed files with 90 additions and 61 deletions

View File

@ -62,7 +62,6 @@ func questionCallback(question alpm.QuestionAny) {
reader := bufio.NewReader(os.Stdin)
numberBuf, overflow, err := reader.ReadLine()
if err != nil {
text.Errorln(err)
break

View File

@ -71,7 +71,7 @@ func gitHasDiff(path, name string) (bool, error) {
// TODO: yay-next passes args through the header, use that to unify ABS and AUR
func gitDownloadABS(url, path, name string) (bool, error) {
if err := os.MkdirAll(path, 0755); err != nil {
if err := os.MkdirAll(path, 0o755); err != nil {
return false, err
}
@ -147,7 +147,6 @@ func getPkgbuilds(pkgs []string, alpmHandle *alpm.Handle, force bool) error {
pkgs = removeInvalidTargets(pkgs)
aur, repo, err := packageSlices(pkgs, alpmHandle)
if err != nil {
return err
}
@ -317,5 +316,6 @@ func getPkgbuildsfromABS(pkgs []string, path string, alpmHandle *alpm.Handle, fo
}
wg.Wait()
return len(missing) != 0, errs.Return()
}

View File

@ -513,7 +513,6 @@ nextpkg:
func parsePackageList(dir string) (pkgdests map[string]string, pkgVersion string, err error) {
stdout, stderr, err := capture(passToMakepkg(dir, "--packagelist"))
if err != nil {
return nil, "", fmt.Errorf("%s %s", stderr, err)
}
@ -772,9 +771,11 @@ func showPkgbuildDiffs(bases []Base, cloned stringset.StringSet) error {
}
}
args := []string{"diff",
args := []string{
"diff",
start + "..HEAD@{upstream}", "--src-prefix",
dir + "/", "--dst-prefix", dir + "/", "--", ".", ":(exclude).SRCINFO"}
dir + "/", "--dst-prefix", dir + "/", "--", ".", ":(exclude).SRCINFO",
}
if text.UseColor {
args = append(args, "--color=always")
} else {

View File

@ -96,7 +96,6 @@ func importKeys(keys []string) error {
text.OperationInfoln(gotext.Get("Importing keys with gpg..."))
err := cmd.Run()
if err != nil {
return errors.New(gotext.Get("problem importing keys"))
}

View File

@ -100,8 +100,10 @@ func TestImportKeys(t *testing.T) {
// 11E521D646982372EB577A1F8F0871F202119294: Tom Stellard.
// B6C8F98282B944E3B0D5C2530FC3042E345AD05D: Hans Wennborg.
{
keys: []string{"11E521D646982372EB577A1F8F0871F202119294",
"B6C8F98282B944E3B0D5C2530FC3042E345AD05D"},
keys: []string{
"11E521D646982372EB577A1F8F0871F202119294",
"B6C8F98282B944E3B0D5C2530FC3042E345AD05D",
},
wantError: false,
},
// Single invalid key, should fail.
@ -117,8 +119,10 @@ func TestImportKeys(t *testing.T) {
// Invalid + valid key. Should fail as well.
// 647F28654894E3BD457199BE38DBBDC86092693E: Greg Kroah-Hartman.
{
keys: []string{"THIS-SHOULD-FAIL",
"647F28654894E3BD457199BE38DBBDC86092693E"},
keys: []string{
"THIS-SHOULD-FAIL",
"647F28654894E3BD457199BE38DBBDC86092693E",
},
wantError: true,
},
}
@ -182,7 +186,8 @@ func TestCheckPgpKeys(t *testing.T) {
{
pkgs: Base{newPkg("libc++")},
srcinfos: map[string]*gosrc.Srcinfo{
"libc++": makeSrcinfo("libc++", "11E521D646982372EB577A1F8F0871F202119294", "B6C8F98282B944E3B0D5C2530FC3042E345AD05D")},
"libc++": makeSrcinfo("libc++", "11E521D646982372EB577A1F8F0871F202119294", "B6C8F98282B944E3B0D5C2530FC3042E345AD05D"),
},
wantError: false,
},
// Two dummy packages requiring the same key.
@ -192,7 +197,8 @@ func TestCheckPgpKeys(t *testing.T) {
srcinfos: map[string]*gosrc.Srcinfo{
"dummy-1": makeSrcinfo("dummy-1",
"ABAF11C65A2970B130ABE3C479BE3E4300411886"),
"dummy-2": makeSrcinfo("dummy-2", "ABAF11C65A2970B130ABE3C479BE3E4300411886")},
"dummy-2": makeSrcinfo("dummy-2", "ABAF11C65A2970B130ABE3C479BE3E4300411886"),
},
wantError: false,
},
// dummy package: single package, two valid keys, one of them already
@ -202,7 +208,8 @@ func TestCheckPgpKeys(t *testing.T) {
{
pkgs: Base{newPkg("dummy-3")},
srcinfos: map[string]*gosrc.Srcinfo{
"dummy-3": makeSrcinfo("dummy-3", "11E521D646982372EB577A1F8F0871F202119294", "C52048C0C0748FEE227D47A2702353E0F7E48EDB")},
"dummy-3": makeSrcinfo("dummy-3", "11E521D646982372EB577A1F8F0871F202119294", "C52048C0C0748FEE227D47A2702353E0F7E48EDB"),
},
wantError: false,
},
// Two dummy packages with existing keys.
@ -210,7 +217,8 @@ func TestCheckPgpKeys(t *testing.T) {
pkgs: Base{newPkg("dummy-4"), newPkg("dummy-5")},
srcinfos: map[string]*gosrc.Srcinfo{
"dummy-4": makeSrcinfo("dummy-4", "11E521D646982372EB577A1F8F0871F202119294"),
"dummy-5": makeSrcinfo("dummy-5", "C52048C0C0748FEE227D47A2702353E0F7E48EDB")},
"dummy-5": makeSrcinfo("dummy-5", "C52048C0C0748FEE227D47A2702353E0F7E48EDB"),
},
wantError: false,
},
// Dummy package with invalid key, should fail.

View File

@ -64,7 +64,7 @@ func initVCS(vcsFilePath string) error {
func initBuildDir() error {
if _, err := os.Stat(config.BuildDir); os.IsNotExist(err) {
if err = os.MkdirAll(config.BuildDir, 0755); err != nil {
if err = os.MkdirAll(config.BuildDir, 0o755); err != nil {
return errors.New(gotext.Get("failed to create BuildDir directory '%s': %s", config.BuildDir, err))
}
} else if err != nil {

View File

@ -30,39 +30,55 @@ func TestParseNumberMenu(t *testing.T) {
}
expected := []result{
{IntRanges{makeIntRange(1, 1),
{IntRanges{
makeIntRange(1, 1),
makeIntRange(2, 2),
makeIntRange(3, 3),
makeIntRange(4, 4),
makeIntRange(5, 5)}, IntRanges{}, make(stringset.StringSet), make(stringset.StringSet)},
{IntRanges{makeIntRange(1, 10),
makeIntRange(5, 15)}, IntRanges{}, make(stringset.StringSet), make(stringset.StringSet)},
{IntRanges{makeIntRange(5, 10),
makeIntRange(85, 90)}, IntRanges{}, make(stringset.StringSet), make(stringset.StringSet)},
{IntRanges{makeIntRange(1, 1),
makeIntRange(99, 99),
makeIntRange(60, 62)},
IntRanges{makeIntRange(2, 2),
makeIntRange(5, 5),
}, IntRanges{}, make(stringset.StringSet), make(stringset.StringSet)},
{IntRanges{
makeIntRange(1, 10),
makeIntRange(5, 15),
}, IntRanges{}, make(stringset.StringSet), make(stringset.StringSet)},
{IntRanges{
makeIntRange(5, 10),
makeIntRange(85, 90),
}, IntRanges{}, make(stringset.StringSet), make(stringset.StringSet)},
{
IntRanges{
makeIntRange(1, 1),
makeIntRange(99, 99),
makeIntRange(60, 62),
},
IntRanges{
makeIntRange(2, 2),
makeIntRange(5, 10),
makeIntRange(38, 40),
makeIntRange(123, 123)},
make(stringset.StringSet), make(stringset.StringSet)},
makeIntRange(123, 123),
},
make(stringset.StringSet), make(stringset.StringSet),
},
{IntRanges{}, IntRanges{}, stringset.Make("abort", "all", "none"), make(stringset.StringSet)},
{IntRanges{}, IntRanges{}, stringset.Make("a-b"), stringset.Make("abort", "a-b")},
{IntRanges{}, IntRanges{}, stringset.Make("-9223372036854775809-9223372036854775809"), make(stringset.StringSet)},
{IntRanges{makeIntRange(1, 1),
{IntRanges{
makeIntRange(1, 1),
makeIntRange(2, 2),
makeIntRange(3, 3),
makeIntRange(4, 4),
makeIntRange(5, 5)}, IntRanges{}, make(stringset.StringSet), make(stringset.StringSet)},
{IntRanges{makeIntRange(1, 1),
makeIntRange(5, 5),
}, IntRanges{}, make(stringset.StringSet), make(stringset.StringSet)},
{IntRanges{
makeIntRange(1, 1),
makeIntRange(2, 2),
makeIntRange(3, 3),
makeIntRange(4, 4),
makeIntRange(5, 5),
makeIntRange(6, 6),
makeIntRange(7, 7),
makeIntRange(8, 8)}, IntRanges{}, make(stringset.StringSet), make(stringset.StringSet)},
makeIntRange(8, 8),
}, IntRanges{}, make(stringset.StringSet), make(stringset.StringSet)},
{IntRanges{}, IntRanges{}, make(stringset.StringSet), make(stringset.StringSet)},
{IntRanges{}, IntRanges{}, make(stringset.StringSet), make(stringset.StringSet)},
{IntRanges{}, IntRanges{}, stringset.Make("a", "b", "c", "d", "e"), make(stringset.StringSet)},
@ -76,7 +92,6 @@ func TestParseNumberMenu(t *testing.T) {
!intRangesEqual(exclude, res.Exclude) ||
!stringset.Equal(otherInclude, res.OtherInclude) ||
!stringset.Equal(otherExclude, res.OtherExclude) {
t.Fatalf("Test %d Failed: Expected: include=%+v exclude=%+v otherInclude=%+v otherExclude=%+v got include=%+v excluive=%+v otherInclude=%+v otherExclude=%+v",
n+1, res.Include, res.Exclude, res.OtherInclude, res.OtherExclude, include, exclude, otherInclude, otherExclude)
}

View File

@ -123,16 +123,20 @@ func TestArguments_CopyGlobal(t *testing.T) {
}{
{name: "simple", fields: fields{
Op: "Q",
Options: map[string]*Option{"a": {}, "arch": {Global: true,
Args: []string{"x86_x64"},
}, "boo": {Global: true, Args: []string{"a", "b"}},
Options: map[string]*Option{
"a": {}, "arch": {
Global: true,
Args: []string{"x86_x64"},
}, "boo": {Global: true, Args: []string{"a", "b"}},
},
Targets: []string{"a", "b"},
}, want: &Arguments{
Op: "",
Options: map[string]*Option{"arch": {Global: true,
Args: []string{"x86_x64"},
}, "boo": {Global: true, Args: []string{"a", "b"}},
Options: map[string]*Option{
"arch": {
Global: true,
Args: []string{"x86_x64"},
}, "boo": {Global: true, Args: []string{"a", "b"}},
},
Targets: []string{},
}},
@ -166,16 +170,19 @@ func TestArguments_Copy(t *testing.T) {
}{
{name: "simple", fields: fields{
Op: "Q",
Options: map[string]*Option{"a": {}, "arch": {
Args: []string{"x86_x64"}, Global: true,
}, "boo": {Args: []string{"a", "b"}, Global: true},
Options: map[string]*Option{
"a": {}, "arch": {
Args: []string{"x86_x64"}, Global: true,
}, "boo": {Args: []string{"a", "b"}, Global: true},
},
Targets: []string{"a", "b"},
}, want: &Arguments{
Op: "Q",
Options: map[string]*Option{"a": {}, "arch": {Global: true,
Args: []string{"x86_x64"},
}, "boo": {Args: []string{"a", "b"}, Global: true},
Options: map[string]*Option{
"a": {}, "arch": {
Global: true,
Args: []string{"x86_x64"},
}, "boo": {Args: []string{"a", "b"}, Global: true},
},
Targets: []string{"a", "b"},
}},

View File

@ -19,8 +19,10 @@ import (
"github.com/Jguer/yay/v10/pkg/text"
)
const arrow = "==>"
const smallArrow = " ->"
const (
arrow = "==>"
smallArrow = " ->"
)
func (warnings *aurWarnings) print() {
if len(warnings.Missing) > 0 {
@ -353,7 +355,7 @@ func localStatistics(alpmHandle *alpm.Handle) error {
return nil
}
//TODO: Make it less hacky
// TODO: Make it less hacky
func printNumberOfUpdates(alpmHandle *alpm.Handle, enableDowngrade bool) error {
warnings := makeWarnings()
old := os.Stdout // keep backup of the real stdout
@ -368,7 +370,7 @@ func printNumberOfUpdates(alpmHandle *alpm.Handle, enableDowngrade bool) error {
return nil
}
//TODO: Make it less hacky
// TODO: Make it less hacky
func printUpdateList(cmdArgs *settings.Arguments, alpmHandle *alpm.Handle, enableDowngrade bool) error {
targets := stringset.FromSlice(cmdArgs.Targets)
warnings := makeWarnings()
@ -513,7 +515,6 @@ func providerMenu(dep string, providers providers) *rpc.Pkg {
reader := bufio.NewReader(os.Stdin)
numberBuf, overflow, err := reader.ReadLine()
if err != nil {
fmt.Fprintln(os.Stderr, err)
break

18
vcs.go
View File

@ -20,13 +20,15 @@ import (
)
// Info contains the last commit sha of a repo
type vcsInfo map[string]shaInfos
type shaInfos map[string]shaInfo
type shaInfo struct {
Protocols []string `json:"protocols"`
Branch string `json:"branch"`
SHA string `json:"sha"`
}
type (
vcsInfo map[string]shaInfos
shaInfos map[string]shaInfo
shaInfo struct {
Protocols []string `json:"protocols"`
Branch string `json:"branch"`
SHA string `json:"sha"`
}
)
// createDevelDB forces yay to create a DB of the existing development packages
func createDevelDB(vcsFilePath string, alpmHandle *alpm.Handle) error {
@ -245,7 +247,7 @@ func saveVCSInfo(vcsFilePath string) error {
if err != nil || string(marshalledinfo) == "null" {
return err
}
in, err := os.OpenFile(vcsFilePath, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0644)
in, err := os.OpenFile(vcsFilePath, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0o644)
if err != nil {
return err
}

View File

@ -5,7 +5,6 @@ import (
)
func isEqual(a, b []string) bool {
if a == nil && b == nil {
return true
}
@ -59,10 +58,8 @@ func TestParsing(t *testing.T) {
if url != compare.URL ||
branch != compare.Branch ||
!isEqual(protocols, compare.Protocols) {
t.Fatalf("Test %d failed: Expected: url=%+v branch=%+v protocols=%+v\ngot url=%+v branch=%+v protocols=%+v",
n+1, compare.URL, compare.Branch, compare.Protocols, url, branch, protocols)
}
}
}