lazyre: the plugin name and export file name regexps compile on first use (#6020)
6af54dc9a(internal/library/plugin.go, pluginName) andb9f8548d2(internal/provider/login_export.go, exportUnsafe) each added a package-level regexp.MustCompile, so TestNoEagerPackageRegexps was red on main on ubuntu and macOS CI (run 42893454569 at51da6f1f5). Both go through lazyre.New now, like the rest sincee4197144a. The patterns and callers are unchanged. yinwu01 found it and had the same patch on a fork branch. Run on mote at this tree (on origin/maind2a80b317): - go vet -tags nogui of internal/library, internal/provider and the root package: ok; gofmt -l clean; - TestNoEagerPackageRegexps: ok (red on main in CI's run above); - internal/cli TestEveryRouteHasACommandOrIsNamed: ok at this head (red in the same CI run, already fixed by91d4eaa70and966ddff20); - go test -tags nogui ./internal/library ./internal/provider: ok. Not run: the full suite, and Windows and Linux vet (a two-line change of how a variable is declared, with no OS-specific files). Co-authored-by: yinwu01 <yinwu01@users.noreply.github.com>
This commit is contained in:
@@ -14,6 +14,8 @@ import (
|
||||
"time"
|
||||
|
||||
"gopkg.in/yaml.v3"
|
||||
|
||||
"github.com/yetone/magpie/internal/lazyre"
|
||||
)
|
||||
|
||||
// A bundle is a Claude Code plugin kept in the library as one item
|
||||
@@ -157,7 +159,7 @@ func inside(dir, p string) (string, bool) {
|
||||
return p, true
|
||||
}
|
||||
|
||||
var pluginName = regexp.MustCompile(`[^A-Za-z0-9_-]+`)
|
||||
var pluginName = lazyre.New(`[^A-Za-z0-9_-]+`)
|
||||
|
||||
func pluginSlug(s string) string {
|
||||
s = strings.Trim(pluginName.ReplaceAllString(strings.TrimSpace(s), "-"), "-_")
|
||||
|
||||
@@ -20,10 +20,11 @@ import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"slices"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/yetone/magpie/internal/lazyre"
|
||||
)
|
||||
|
||||
// Export formats.
|
||||
@@ -155,7 +156,7 @@ func ExportLogins(agent, format string, users []string) (ExportResult, error) {
|
||||
return res, nil
|
||||
}
|
||||
|
||||
var exportUnsafe = regexp.MustCompile(`[^A-Za-z0-9@._+-]+`)
|
||||
var exportUnsafe = lazyre.New(`[^A-Za-z0-9@._+-]+`)
|
||||
|
||||
// exportName is CLIProxyAPI's name for an auth file: <type>-<email>.json,
|
||||
// a ChatGPT one's plan after the email.
|
||||
|
||||
Reference in New Issue
Block a user