update: the urgent-release line compiles on first use

TestNoEagerPackageRegexps (root package) was red on main since
36eebea13: internal/update/behind.go:122 compiled urgentLine with
regexp.MustCompile at package level. Main's Test run 43201591823 (at
67f61bd78) failed on it on macOS and ubuntu. It now uses lazyre.New;
its one call is MatchString, which lazyre has.

Run on mote at origin/main f6c882ad7 + this: go test -run
TestNoEagerPackageRegexps . ok (red with the old line put back:
behind.go:122:18); go test ./internal/update ok; go vet of
internal/update, linux nogui and windows; gofmt -l empty.
This commit is contained in:
yetone
2026-11-12 19:37:24 +08:00
parent 17345f684f
commit 10e783080a
+2 -2
View File
@@ -13,11 +13,11 @@ import (
"encoding/json"
"os"
"path/filepath"
"regexp"
"sync"
"time"
"github.com/yetone/magpie/internal/appdir"
"github.com/yetone/magpie/internal/lazyre"
)
// Quiet is how long a version has to be behind before the pill lights, and
@@ -119,7 +119,7 @@ func (b Behind) Lit(current string, now time.Time) bool {
return !b.Since.IsZero() && now.Sub(b.Since) >= Quiet
}
var urgentLine = regexp.MustCompile(`(?im)^[ \t]*(?:>[ \t]*)?\*\*urgent release:\*\*`)
var urgentLine = lazyre.New(`(?im)^[ \t]*(?:>[ \t]*)?\*\*urgent release:\*\*`)
// UrgentIn is whether a release's notes mark it urgent, as the site reads
// them (site/worker.js, urgentIn).