mirror of
https://github.com/Jguer/yay.git
synced 2025-10-07 00:14:22 -04:00
Re-add functionality for Installed and NotInstalled options in the menus (#2233)
* fix(menus): Handle Installed and NotInstalled options correctly in the menus This functionality was temporarily removed. This commit adds that functionality back. * fix(tests): Mock InstalledRemotePackageNamesFn when necessary
This commit is contained in:
parent
6dd7933fbe
commit
dadc8c0d98
@ -139,6 +139,7 @@ func TestIntegrationLocalInstall(t *testing.T) {
|
|||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
LocalPackageFn: func(s string) mock.IPackage { return nil },
|
LocalPackageFn: func(s string) mock.IPackage { return nil },
|
||||||
|
InstalledRemotePackageNamesFn: func() []string { return []string{} },
|
||||||
}
|
}
|
||||||
|
|
||||||
config := &settings.Configuration{
|
config := &settings.Configuration{
|
||||||
@ -417,6 +418,7 @@ func TestIntegrationLocalInstallNeeded(t *testing.T) {
|
|||||||
|
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
|
InstalledRemotePackageNamesFn: func() []string { return []string{} },
|
||||||
}
|
}
|
||||||
|
|
||||||
config := &settings.Configuration{
|
config := &settings.Configuration{
|
||||||
@ -580,6 +582,7 @@ func TestIntegrationLocalInstallGenerateSRCINFO(t *testing.T) {
|
|||||||
|
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
|
InstalledRemotePackageNamesFn: func() []string { return []string{} },
|
||||||
}
|
}
|
||||||
|
|
||||||
config := &settings.Configuration{
|
config := &settings.Configuration{
|
||||||
@ -842,6 +845,7 @@ func TestIntegrationLocalInstallWithDepsProvides(t *testing.T) {
|
|||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
LocalPackageFn: func(s string) mock.IPackage { return nil },
|
LocalPackageFn: func(s string) mock.IPackage { return nil },
|
||||||
|
InstalledRemotePackageNamesFn: func() []string { return []string{} },
|
||||||
}
|
}
|
||||||
|
|
||||||
config := &settings.Configuration{
|
config := &settings.Configuration{
|
||||||
@ -981,6 +985,7 @@ func TestIntegrationLocalInstallTwoSrcInfosWithDeps(t *testing.T) {
|
|||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
LocalPackageFn: func(s string) mock.IPackage { return nil },
|
LocalPackageFn: func(s string) mock.IPackage { return nil },
|
||||||
|
InstalledRemotePackageNamesFn: func() []string { return []string{} },
|
||||||
}
|
}
|
||||||
|
|
||||||
config := &settings.Configuration{
|
config := &settings.Configuration{
|
||||||
|
@ -23,7 +23,9 @@ func anyExistInCache(pkgbuildDirs map[string]string) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func CleanFn(ctx context.Context, config *settings.Configuration, w io.Writer, pkgbuildDirsByBase map[string]string) error {
|
func CleanFn(ctx context.Context, config *settings.Configuration, w io.Writer,
|
||||||
|
pkgbuildDirsByBase map[string]string, installed mapset.Set[string],
|
||||||
|
) error {
|
||||||
if len(pkgbuildDirsByBase) == 0 {
|
if len(pkgbuildDirsByBase) == 0 {
|
||||||
return nil // no work to do
|
return nil // no work to do
|
||||||
}
|
}
|
||||||
@ -47,8 +49,7 @@ func CleanFn(ctx context.Context, config *settings.Configuration, w io.Writer, p
|
|||||||
bases = append(bases, pkg)
|
bases = append(bases, pkg)
|
||||||
}
|
}
|
||||||
|
|
||||||
// TOFIX: empty installed slice means installed filter is disabled
|
toClean, errClean := selectionMenu(w, pkgbuildDirsByBase, bases, installed,
|
||||||
toClean, errClean := selectionMenu(w, pkgbuildDirsByBase, bases, mapset.NewSet[string](),
|
|
||||||
gotext.Get("Packages to cleanBuild?"),
|
gotext.Get("Packages to cleanBuild?"),
|
||||||
settings.NoConfirm, config.AnswerClean, skipFunc)
|
settings.NoConfirm, config.AnswerClean, skipFunc)
|
||||||
if errClean != nil {
|
if errClean != nil {
|
||||||
|
@ -90,7 +90,7 @@ func gitHasDiff(ctx context.Context, cmdBuilder exe.ICmdBuilder, dir string) (bo
|
|||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return wether or not we have reviewed a diff yet. It checks for the existence of
|
// Return whether or not we have reviewed a diff yet. It checks for the existence of
|
||||||
// YAY_DIFF_REVIEW in the git ref-list.
|
// YAY_DIFF_REVIEW in the git ref-list.
|
||||||
func gitHasLastSeenRef(ctx context.Context, cmdBuilder exe.ICmdBuilder, dir string) bool {
|
func gitHasLastSeenRef(ctx context.Context, cmdBuilder exe.ICmdBuilder, dir string) bool {
|
||||||
_, _, err := cmdBuilder.Capture(
|
_, _, err := cmdBuilder.Capture(
|
||||||
@ -145,7 +145,9 @@ func updatePkgbuildSeenRef(ctx context.Context, cmdBuilder exe.ICmdBuilder, pkgb
|
|||||||
return errMulti.Return()
|
return errMulti.Return()
|
||||||
}
|
}
|
||||||
|
|
||||||
func DiffFn(ctx context.Context, config *settings.Configuration, w io.Writer, pkgbuildDirsByBase map[string]string) error {
|
func DiffFn(ctx context.Context, config *settings.Configuration, w io.Writer,
|
||||||
|
pkgbuildDirsByBase map[string]string, installed mapset.Set[string],
|
||||||
|
) error {
|
||||||
if len(pkgbuildDirsByBase) == 0 {
|
if len(pkgbuildDirsByBase) == 0 {
|
||||||
return nil // no work to do
|
return nil // no work to do
|
||||||
}
|
}
|
||||||
@ -155,7 +157,7 @@ func DiffFn(ctx context.Context, config *settings.Configuration, w io.Writer, pk
|
|||||||
bases = append(bases, base)
|
bases = append(bases, base)
|
||||||
}
|
}
|
||||||
|
|
||||||
toDiff, errMenu := selectionMenu(w, pkgbuildDirsByBase, bases, mapset.NewThreadUnsafeSet[string](), gotext.Get("Diffs to show?"),
|
toDiff, errMenu := selectionMenu(w, pkgbuildDirsByBase, bases, installed, gotext.Get("Diffs to show?"),
|
||||||
settings.NoConfirm, config.AnswerDiff, nil)
|
settings.NoConfirm, config.AnswerDiff, nil)
|
||||||
if errMenu != nil || len(toDiff) == 0 {
|
if errMenu != nil || len(toDiff) == 0 {
|
||||||
return errMenu
|
return errMenu
|
||||||
|
@ -114,7 +114,7 @@ func editPkgbuilds(log *text.Logger, pkgbuildDirs map[string]string, bases []str
|
|||||||
}
|
}
|
||||||
|
|
||||||
func EditFn(ctx context.Context, cfg *settings.Configuration, w io.Writer,
|
func EditFn(ctx context.Context, cfg *settings.Configuration, w io.Writer,
|
||||||
pkgbuildDirsByBase map[string]string,
|
pkgbuildDirsByBase map[string]string, installed mapset.Set[string],
|
||||||
) error {
|
) error {
|
||||||
if len(pkgbuildDirsByBase) == 0 {
|
if len(pkgbuildDirsByBase) == 0 {
|
||||||
return nil // no work to do
|
return nil // no work to do
|
||||||
@ -125,8 +125,7 @@ func EditFn(ctx context.Context, cfg *settings.Configuration, w io.Writer,
|
|||||||
bases = append(bases, pkg)
|
bases = append(bases, pkg)
|
||||||
}
|
}
|
||||||
|
|
||||||
toEdit, errMenu := selectionMenu(w, pkgbuildDirsByBase, bases,
|
toEdit, errMenu := selectionMenu(w, pkgbuildDirsByBase, bases, installed,
|
||||||
mapset.NewThreadUnsafeSet[string](),
|
|
||||||
gotext.Get("PKGBUILDs to edit?"), settings.NoConfirm, cfg.AnswerEdit, nil)
|
gotext.Get("PKGBUILDs to edit?"), settings.NoConfirm, cfg.AnswerEdit, nil)
|
||||||
if errMenu != nil || len(toEdit) == 0 {
|
if errMenu != nil || len(toEdit) == 0 {
|
||||||
return errMenu
|
return errMenu
|
||||||
|
@ -29,7 +29,9 @@ const (
|
|||||||
PreDownloadSourcesHook HookType = "pre-download-sources"
|
PreDownloadSourcesHook HookType = "pre-download-sources"
|
||||||
)
|
)
|
||||||
|
|
||||||
type HookFn func(ctx context.Context, config *settings.Configuration, w io.Writer, pkgbuildDirsByBase map[string]string) error
|
type HookFn func(ctx context.Context, config *settings.Configuration, w io.Writer,
|
||||||
|
pkgbuildDirsByBase map[string]string, installed mapset.Set[string],
|
||||||
|
) error
|
||||||
|
|
||||||
type Hook struct {
|
type Hook struct {
|
||||||
Name string
|
Name string
|
||||||
@ -214,9 +216,11 @@ func (preper *Preparer) PrepareWorkspace(ctx context.Context, targets []map[stri
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
remoteNames := preper.dbExecutor.InstalledRemotePackageNames()
|
||||||
|
remoteNamesCache := mapset.NewThreadUnsafeSet(remoteNames...)
|
||||||
for _, hookFn := range preper.hooks {
|
for _, hookFn := range preper.hooks {
|
||||||
if hookFn.Type == PreDownloadSourcesHook {
|
if hookFn.Type == PreDownloadSourcesHook {
|
||||||
if err := hookFn.Hookfn(ctx, preper.cfg, os.Stdout, pkgBuildDirsByBase); err != nil {
|
if err := hookFn.Hookfn(ctx, preper.cfg, os.Stdout, pkgBuildDirsByBase, remoteNamesCache); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user