mirror of
https://github.com/Jguer/yay.git
synced 2024-11-06 09:07:21 +01:00
Simplify formatPkgBase
Only pass the packages belonging to the desired pkgbase. Before our entire list of every pkgbase had to be passed, as well as an example package from the base we are looking for. This lets use use formatPkgBase easier in other places outside of install. Many of the functions in install could also be simplified in a similar way, although that has not been done in this commit.
This commit is contained in:
parent
0e40d9a3f6
commit
3dc350d3ac
16
install.go
16
install.go
@ -94,7 +94,7 @@ func install(parser *arguments) error {
|
||||
}
|
||||
|
||||
for up := range aurUp {
|
||||
requestTargets = append(requestTargets, "aur/" + up)
|
||||
requestTargets = append(requestTargets, "aur/"+up)
|
||||
parser.addTarget("aur/" + up)
|
||||
}
|
||||
|
||||
@ -493,7 +493,7 @@ func pkgbuildNumberMenu(pkgs []*rpc.Pkg, bases map[string][]*rpc.Pkg, installed
|
||||
dir := filepath.Join(config.BuildDir, pkg.PackageBase)
|
||||
|
||||
toPrint += fmt.Sprintf(magenta("%3d")+" %-40s", len(pkgs)-n,
|
||||
bold(formatPkgbase(pkg, bases)))
|
||||
bold(formatPkgbase(bases[pkg.PackageBase])))
|
||||
if installed.get(pkg.Name) {
|
||||
toPrint += bold(green(" (Installed)"))
|
||||
}
|
||||
@ -669,7 +669,7 @@ func showPkgBuildDiffs(pkgs []*rpc.Pkg, bases map[string][]*rpc.Pkg, cloned stri
|
||||
}
|
||||
|
||||
if !hasDiff {
|
||||
fmt.Printf("%s %s: %s\n", bold(yellow(arrow)), cyan(formatPkgbase(pkg, bases)), bold("No changes -- skipping"))
|
||||
fmt.Printf("%s %s: %s\n", bold(yellow(arrow)), cyan(formatPkgbase(bases[pkg.PackageBase])), bold("No changes -- skipping"))
|
||||
continue
|
||||
}
|
||||
}
|
||||
@ -732,7 +732,7 @@ func parseSRCINFOFiles(pkgs []*rpc.Pkg, srcinfos map[string]*gosrc.Srcinfo, base
|
||||
dir := filepath.Join(config.BuildDir, pkg.PackageBase)
|
||||
|
||||
str := bold(cyan("::") + " Parsing SRCINFO (%d/%d): %s\n")
|
||||
fmt.Printf(str, k+1, len(pkgs), cyan(formatPkgbase(pkg, bases)))
|
||||
fmt.Printf(str, k+1, len(pkgs), cyan(formatPkgbase(bases[pkg.PackageBase])))
|
||||
|
||||
pkgbuild, err := gosrc.ParseFile(filepath.Join(dir, ".SRCINFO"))
|
||||
if err != nil {
|
||||
@ -750,7 +750,7 @@ func tryParsesrcinfosFile(pkgs []*rpc.Pkg, srcinfos map[string]*gosrc.Srcinfo, b
|
||||
dir := filepath.Join(config.BuildDir, pkg.PackageBase)
|
||||
|
||||
str := bold(cyan("::") + " Parsing SRCINFO (%d/%d): %s\n")
|
||||
fmt.Printf(str, k+1, len(pkgs), cyan(formatPkgbase(pkg, bases)))
|
||||
fmt.Printf(str, k+1, len(pkgs), cyan(formatPkgbase(bases[pkg.PackageBase])))
|
||||
|
||||
pkgbuild, err := gosrc.ParseFile(filepath.Join(dir, ".SRCINFO"))
|
||||
if err != nil {
|
||||
@ -808,7 +808,7 @@ func downloadPkgBuilds(pkgs []*rpc.Pkg, bases map[string][]*rpc.Pkg, toSkip stri
|
||||
mux.Lock()
|
||||
downloaded++
|
||||
str := bold(cyan("::") + " PKGBUILD up to date, Skipping (%d/%d): %s\n")
|
||||
fmt.Printf(str, downloaded, len(pkgs), cyan(formatPkgbase(pkg, bases)))
|
||||
fmt.Printf(str, downloaded, len(pkgs), cyan(formatPkgbase(bases[pkg.PackageBase])))
|
||||
mux.Unlock()
|
||||
return
|
||||
}
|
||||
@ -835,7 +835,7 @@ func downloadPkgBuilds(pkgs []*rpc.Pkg, bases map[string][]*rpc.Pkg, toSkip stri
|
||||
mux.Lock()
|
||||
downloaded++
|
||||
str := bold(cyan("::") + " Downloaded PKGBUILD (%d/%d): %s\n")
|
||||
fmt.Printf(str, downloaded, len(pkgs), cyan(formatPkgbase(pkg, bases)))
|
||||
fmt.Printf(str, downloaded, len(pkgs), cyan(formatPkgbase(bases[pkg.PackageBase])))
|
||||
mux.Unlock()
|
||||
}
|
||||
|
||||
@ -860,7 +860,7 @@ func downloadPkgBuildsSources(pkgs []*rpc.Pkg, bases map[string][]*rpc.Pkg, inco
|
||||
|
||||
err = show(passToMakepkg(dir, args...))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error downloading sources: %s", cyan(formatPkgbase(pkg, bases)))
|
||||
return fmt.Errorf("Error downloading sources: %s", cyan(formatPkgbase(bases[pkg.PackageBase])))
|
||||
}
|
||||
}
|
||||
|
||||
|
2
keys.go
2
keys.go
@ -115,7 +115,7 @@ func formatKeysToImport(keys pgpKeySet, bases map[string][]*rpc.Pkg) (string, er
|
||||
for key, pkgs := range keys {
|
||||
pkglist := ""
|
||||
for _, pkg := range pkgs {
|
||||
pkglist += formatPkgbase(pkg, bases) + " "
|
||||
pkglist += formatPkgbase(bases[pkg.PackageBase]) + " "
|
||||
}
|
||||
pkglist = strings.TrimRight(pkglist, " ")
|
||||
buffer.WriteString(fmt.Sprintf("\n%s %s, required by: %s", yellow(bold(smallArrow)), cyan(key), cyan(pkglist)))
|
||||
|
7
print.go
7
print.go
@ -143,11 +143,12 @@ 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(pkg *rpc.Pkg, bases map[string][]*rpc.Pkg) string {
|
||||
func formatPkgbase(base []*rpc.Pkg) string {
|
||||
pkg := base[0]
|
||||
str := pkg.PackageBase
|
||||
if len(bases[pkg.PackageBase]) > 1 || pkg.PackageBase != pkg.Name {
|
||||
if len(base) > 1 || pkg.PackageBase != pkg.Name {
|
||||
str2 := " ("
|
||||
for _, split := range bases[pkg.PackageBase] {
|
||||
for _, split := range base {
|
||||
str2 += split.Name + " "
|
||||
}
|
||||
str2 = str2[:len(str2)-1] + ")"
|
||||
|
Loading…
Reference in New Issue
Block a user