implement formatPkgbase as Base.String

Now that Base is its own type, it is much neater to have this as its
stringer function.
This commit is contained in:
morganamilo 2018-08-11 05:39:24 +01:00
parent afee400662
commit 40776fa184
No known key found for this signature in database
GPG Key ID: 6FE9E7996B0B082E
3 changed files with 13 additions and 13 deletions

View File

@ -438,7 +438,7 @@ nextpkg:
fmt.Println()
fmt.Print(bold(yellow(arrow)) + " The following packages are not compatible with your architecture:")
for pkg := range incompatible {
fmt.Print(" " + cyan(formatPkgbase(basesMap[pkg])))
fmt.Print(" " + cyan((basesMap[pkg].String())))
}
fmt.Println()
@ -494,7 +494,7 @@ func pkgbuildNumberMenu(bases []Base, installed stringSet) bool {
dir := filepath.Join(config.BuildDir, pkg)
toPrint += fmt.Sprintf(magenta("%3d")+" %-40s", len(bases)-n,
bold(formatPkgbase(base)))
bold(base.String()))
anyInstalled := false
for _, b := range base {
@ -689,7 +689,7 @@ func showPkgbuildDiffs(bases []Base, cloned stringSet) error {
}
if !hasDiff {
fmt.Printf("%s %s: %s\n", bold(yellow(arrow)), cyan(formatPkgbase(base)), bold("No changes -- skipping"))
fmt.Printf("%s %s: %s\n", bold(yellow(arrow)), cyan(base.String()), bold("No changes -- skipping"))
continue
}
}
@ -755,15 +755,15 @@ func parseSrcinfoFiles(bases []Base, errIsFatal bool) (map[string]*gosrc.Srcinfo
dir := filepath.Join(config.BuildDir, pkg)
str := bold(cyan("::") + " Parsing SRCINFO (%d/%d): %s\n")
fmt.Printf(str, k+1, len(bases), cyan(formatPkgbase(base)))
fmt.Printf(str, k+1, len(bases), cyan(base.String()))
pkgbuild, err := gosrc.ParseFile(filepath.Join(dir, ".SRCINFO"))
if err != nil {
if !errIsFatal {
fmt.Printf("failed to parse %s -- skipping: %s\n", formatPkgbase(base), err)
fmt.Printf("failed to parse %s -- skipping: %s\n", base.String(), err)
continue
}
return nil, fmt.Errorf("failed to parse %s: %s", formatPkgbase(base), err)
return nil, fmt.Errorf("failed to parse %s: %s", base.String(), err)
}
srcinfos[pkg] = pkgbuild
@ -824,7 +824,7 @@ func downloadPkgbuilds(bases []Base, toSkip stringSet) (stringSet, error) {
mux.Lock()
downloaded++
str := bold(cyan("::") + " PKGBUILD up to date, Skipping (%d/%d): %s\n")
fmt.Printf(str, downloaded, len(bases), cyan(formatPkgbase(base)))
fmt.Printf(str, downloaded, len(bases), cyan(base.String()))
mux.Unlock()
return
}
@ -851,7 +851,7 @@ func downloadPkgbuilds(bases []Base, toSkip stringSet) (stringSet, error) {
mux.Lock()
downloaded++
str := bold(cyan("::") + " Downloaded PKGBUILD (%d/%d): %s\n")
fmt.Printf(str, downloaded, len(bases), cyan(formatPkgbase(base)))
fmt.Printf(str, downloaded, len(bases), cyan(base.String()))
mux.Unlock()
}
@ -877,7 +877,7 @@ func downloadPkgbuildsSources(bases []Base, incompatible stringSet) (err error)
err = show(passToMakepkg(dir, args...))
if err != nil {
return fmt.Errorf("Error downloading sources: %s", cyan(formatPkgbase(base)))
return fmt.Errorf("Error downloading sources: %s", cyan(base.String()))
}
}
@ -901,7 +901,7 @@ func buildInstallPkgbuilds(dp *depPool, do *depOrder, srcinfos map[string]*gosrc
//pkgver bump
err := show(passToMakepkg(dir, args...))
if err != nil {
return fmt.Errorf("Error making: %s", formatPkgbase(base))
return fmt.Errorf("Error making: %s", base.String())
}
pkgdests, version, err := parsePackageList(dir)
@ -943,7 +943,7 @@ func buildInstallPkgbuilds(dp *depPool, do *depOrder, srcinfos map[string]*gosrc
err := show(passToMakepkg(dir, args...))
if err != nil {
return fmt.Errorf("Error making: %s", formatPkgbase(base))
return fmt.Errorf("Error making: %s", base.String())
}
}

View File

@ -112,7 +112,7 @@ func formatKeysToImport(keys pgpKeySet) (string, error) {
for key, bases := range keys {
pkglist := ""
for _, base := range bases {
pkglist += formatPkgbase(base) + " "
pkglist += base.String() + " "
}
pkglist = strings.TrimRight(pkglist, " ")
buffer.WriteString(fmt.Sprintf("\n%s %s, required by: %s", yellow(bold(smallArrow)), cyan(key), cyan(pkglist)))

View File

@ -143,7 +143,7 @@ func (s repoQuery) printSearch() {
// Pretty print a set of packages from the same package base.
// Packages foo and bar from a pkgbase named base would print like so:
// base (foo bar)
func formatPkgbase(base []*rpc.Pkg) string {
func (base Base) String() string {
pkg := base[0]
str := pkg.PackageBase
if len(base) > 1 || pkg.PackageBase != pkg.Name {