Merge pull request #504 from Morganamilo/noask

Remove default usage of --ask
This commit is contained in:
Anna 2018-06-24 16:30:28 +01:00 committed by GitHub
commit 77a5cf5c69
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 38 additions and 13 deletions

4
cmd.go
View File

@ -341,6 +341,10 @@ func handleConfig(option, value string) bool {
config.EditMenu = true config.EditMenu = true
case "noeditmenu": case "noeditmenu":
config.EditMenu = false config.EditMenu = false
case "useask":
config.UseAsk = true
case "nouseask":
config.UseAsk = false
case "a", "aur": case "a", "aur":
mode = ModeAUR mode = ModeAUR
case "repo": case "repo":

View File

@ -69,6 +69,7 @@ type Configuration struct {
CleanMenu bool `json:"cleanmenu"` CleanMenu bool `json:"cleanmenu"`
DiffMenu bool `json:"diffmenu"` DiffMenu bool `json:"diffmenu"`
EditMenu bool `json:"editmenu"` EditMenu bool `json:"editmenu"`
UseAsk bool `json:"useask"`
} }
var version = "7.885" var version = "7.885"
@ -177,6 +178,7 @@ func defaultSettings(config *Configuration) {
config.CleanMenu = true config.CleanMenu = true
config.DiffMenu = true config.DiffMenu = true
config.EditMenu = false config.EditMenu = false
config.UseAsk = false
} }
// Editor returns the preferred system editor. // Editor returns the preferred system editor.

View File

@ -124,7 +124,7 @@ func (dp *depPool) checkReverseConflicts(conflicts mapStringSet) {
}) })
} }
func (dp *depPool) CheckConflicts() error { func (dp *depPool) CheckConflicts() (mapStringSet, error) {
var wg sync.WaitGroup var wg sync.WaitGroup
innerConflicts := make(mapStringSet) innerConflicts := make(mapStringSet)
conflicts := make(mapStringSet) conflicts := make(mapStringSet)
@ -159,12 +159,17 @@ func (dp *depPool) CheckConflicts() error {
fmt.Println(str) fmt.Println(str)
} }
return fmt.Errorf("Unresolvable package conflicts, aborting") return nil, fmt.Errorf("Unresolvable package conflicts, aborting")
} }
if len(conflicts) != 0 { if len(conflicts) != 0 {
fmt.Println() fmt.Println()
fmt.Println(bold(red(arrow)), bold("Package conflicts found:")) fmt.Println(bold(red(arrow)), bold("Package conflicts found:"))
if !config.UseAsk {
fmt.Println(bold(red(arrow)), bold("You will have to confirm these when installing"))
}
for name, pkgs := range conflicts { for name, pkgs := range conflicts {
str := red(bold(smallArrow)) + " Installing " + cyan(name) + " will remove:" str := red(bold(smallArrow)) + " Installing " + cyan(name) + " will remove:"
for pkg := range pkgs { for pkg := range pkgs {
@ -178,7 +183,7 @@ func (dp *depPool) CheckConflicts() error {
fmt.Println() fmt.Println()
} }
return nil return conflicts, nil
} }
type missing struct { type missing struct {

View File

@ -116,7 +116,7 @@ func install(parser *arguments) error {
return fmt.Errorf(bold(red(arrow)) + " Refusing to install AUR Packages as root, Aborting.") return fmt.Errorf(bold(red(arrow)) + " Refusing to install AUR Packages as root, Aborting.")
} }
err = dp.CheckConflicts() conflicts, err := dp.CheckConflicts()
if err != nil { if err != nil {
return err return err
} }
@ -279,17 +279,12 @@ func install(parser *arguments) error {
} }
} }
//conflicts have been checked so answer y for them
ask, _ := strconv.Atoi(cmdArgs.globals["ask"])
uask := alpm.QuestionType(ask) | alpm.QuestionTypeConflictPkg
cmdArgs.globals["ask"] = fmt.Sprint(uask)
err = downloadPkgBuildsSources(do.Aur, do.Bases, incompatible) err = downloadPkgBuildsSources(do.Aur, do.Bases, incompatible)
if err != nil { if err != nil {
return err return err
} }
err = buildInstallPkgBuilds(dp, do, srcinfosStale, parser, incompatible) err = buildInstallPkgBuilds(dp, do, srcinfosStale, parser, incompatible, conflicts)
if err != nil { if err != nil {
return err return err
} }
@ -745,7 +740,7 @@ func downloadPkgBuildsSources(pkgs []*rpc.Pkg, bases map[string][]*rpc.Pkg, inco
return return
} }
func buildInstallPkgBuilds(dp *depPool, do *depOrder, srcinfos map[string]*gopkg.PKGBUILD, parser *arguments, incompatible stringSet) error { func buildInstallPkgBuilds(dp *depPool, do *depOrder, srcinfos map[string]*gopkg.PKGBUILD, parser *arguments, incompatible stringSet, conflicts mapStringSet) error {
for _, pkg := range do.Aur { for _, pkg := range do.Aur {
dir := filepath.Join(config.BuildDir, pkg.PackageBase) dir := filepath.Join(config.BuildDir, pkg.PackageBase)
built := true built := true
@ -807,6 +802,7 @@ func buildInstallPkgBuilds(dp *depPool, do *depOrder, srcinfos map[string]*gopkg
arguments.clearTargets() arguments.clearTargets()
arguments.op = "U" arguments.op = "U"
arguments.delArg("confirm") arguments.delArg("confirm")
arguments.delArg("noconfirm")
arguments.delArg("c", "clean") arguments.delArg("c", "clean")
arguments.delArg("q", "quiet") arguments.delArg("q", "quiet")
arguments.delArg("q", "quiet") arguments.delArg("q", "quiet")
@ -814,6 +810,26 @@ func buildInstallPkgBuilds(dp *depPool, do *depOrder, srcinfos map[string]*gopkg
arguments.delArg("u", "sysupgrade") arguments.delArg("u", "sysupgrade")
arguments.delArg("w", "downloadonly") arguments.delArg("w", "downloadonly")
oldConfirm := config.NoConfirm
//conflicts have been checked so answer y for them
if config.UseAsk {
ask, _ := strconv.Atoi(cmdArgs.globals["ask"])
uask := alpm.QuestionType(ask) | alpm.QuestionTypeConflictPkg
cmdArgs.globals["ask"] = fmt.Sprint(uask)
} else {
conflict := false
for _, split := range do.Bases[pkg.PackageBase] {
if _, ok := conflicts[split.Name]; ok {
conflict = true
}
}
if !conflict {
config.NoConfirm = true
}
}
depArguments := makeArguments() depArguments := makeArguments()
depArguments.addArg("D", "asdeps") depArguments.addArg("D", "asdeps")
expArguments := makeArguments() expArguments := makeArguments()
@ -850,8 +866,6 @@ func buildInstallPkgBuilds(dp *depPool, do *depOrder, srcinfos map[string]*gopkg
} }
} }
oldConfirm := config.NoConfirm
config.NoConfirm = true
err = passToPacman(arguments) err = passToPacman(arguments)
if err != nil { if err != nil {
return err return err