refactor: using slices.Contains to simplify the code

Signed-off-by: crystalstall <crystalruby@qq.com>
pull/13602/head
crystalstall 8 months ago
parent 6fe37ef26f
commit 09cf0b9858

@ -19,6 +19,7 @@ package main
import (
"fmt"
"io"
"slices"
"sync"
"github.com/pkg/errors"
@ -158,10 +159,5 @@ func checkRequestedRepos(requestedRepos []string, validRepos []*repo.Entry) erro
}
func isRepoRequested(repoName string, requestedRepos []string) bool {
for _, requestedRepo := range requestedRepos {
if repoName == requestedRepo {
return true
}
}
return false
return slices.Contains(requestedRepos, repoName)
}

@ -24,6 +24,7 @@ import (
"path"
"path/filepath"
"regexp"
"slices"
"sort"
"strings"
@ -206,12 +207,7 @@ func newTemplateCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
}
func isTestHook(h *release.Hook) bool {
for _, e := range h.Events {
if e == release.HookTest {
return true
}
}
return false
return slices.Contains(h.Events, release.HookTest)
}
// The following functions (writeToFile, createOrOpenFile, and ensureDirectoryForFile)

Loading…
Cancel
Save