Permalink
Browse files

implement formatPkgbase as Base.String

Now that Base is its own type, it is much neater to have this as its
stringer function.
  • Loading branch information...
Morganamilo committed Aug 11, 2018
1 parent afee400 commit 40776fa18457854170400f771239868b8e2a6257
Showing with 13 additions and 13 deletions.
  1. +11 −11 install.go
  2. +1 −1 keys.go
  3. +1 −1 print.go
View
@@ -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
@@ -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
@@ -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 {

0 comments on commit 40776fa

Please sign in to comment.