From 99e55725fb0783bc3280498ec6047350368c25d7 Mon Sep 17 00:00:00 2001 From: Jesse Duffield Date: Sun, 20 Mar 2022 16:18:58 +1100 Subject: [PATCH] simplify --- pkg/app/app.go | 6 ++---- pkg/commands/git_commands/bisect_info.go | 14 ++++++-------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/pkg/app/app.go b/pkg/app/app.go index eeb1b849f..c81332df0 100644 --- a/pkg/app/app.go +++ b/pkg/app/app.go @@ -296,10 +296,8 @@ func (app *App) KnownError(err error) (string, bool) { knownErrorMessages := []string{app.Tr.MinGitVersionError} - if message, ok := slices.Find(knownErrorMessages, func(knownErrorMessage string) bool { - return knownErrorMessage == errorMessage - }); ok { - return message, true + if slices.Contains(knownErrorMessages, errorMessage) { + return errorMessage, true } mappings := []errorMapping{ diff --git a/pkg/commands/git_commands/bisect_info.go b/pkg/commands/git_commands/bisect_info.go index 5b3b1f028..ea20d0d38 100644 --- a/pkg/commands/git_commands/bisect_info.go +++ b/pkg/commands/git_commands/bisect_info.go @@ -1,6 +1,10 @@ package git_commands -import "github.com/sirupsen/logrus" +import ( + "github.com/jesseduffield/generics/maps" + "github.com/jesseduffield/generics/slices" + "github.com/sirupsen/logrus" +) // although the typical terms in a git bisect are 'bad' and 'good', they're more // generally known as 'new' and 'old'. Semi-recently git allowed the user to define @@ -93,11 +97,5 @@ func (self *BisectInfo) Bisecting() bool { return false } - for _, status := range self.statusMap { - if status == BisectStatusOld { - return true - } - } - - return false + return slices.Contains(maps.Values(self.statusMap), BisectStatusOld) }