From 083c3ee659c6c5542687f3bafae68cbc24dbc90f Mon Sep 17 00:00:00 2001 From: Joe Chen Date: Sat, 25 Jun 2022 18:07:39 +0800 Subject: db: refactor "action" table to use GORM (#7054) Co-authored-by: deepsource-autofix[bot] <62050782+deepsource-autofix[bot]@users.noreply.github.com> --- internal/lazyregexp/lazyre.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'internal/lazyregexp') diff --git a/internal/lazyregexp/lazyre.go b/internal/lazyregexp/lazyre.go index 79ce5a18..e4c9f7ea 100644 --- a/internal/lazyregexp/lazyre.go +++ b/internal/lazyregexp/lazyre.go @@ -7,10 +7,10 @@ package lazyregexp import ( - "os" "regexp" - "strings" "sync" + + "gogs.io/gogs/internal/testutil" ) // Regexp is a wrapper around regexp.Regexp, where the underlying regexp will be @@ -99,14 +99,12 @@ func (r *Regexp) ReplaceAll(src, repl []byte) []byte { return r.Regexp().ReplaceAll(src, repl) } -var inTest = len(os.Args) > 0 && strings.HasSuffix(strings.TrimSuffix(os.Args[0], ".exe"), ".test") - // New creates a new lazy regexp, delaying the compiling work until it is first // needed. If the code is being run as part of tests, the regexp compiling will // happen immediately. func New(str string) *Regexp { lr := &Regexp{str: str} - if inTest { + if testutil.InTest { // In tests, always compile the regexps early. lr.Regexp() } -- cgit v1.2.3