ssharpcc on X reads every changelog before updating, for fear of a ban
when behind, and with many releases a day that is a lot of reading.
Settings → About → Update channel (zh: 更新渠道, 稳定版 / 每个版本) picks
Every version, the default and today's behaviour, or Stable: one version
a week, the newest that had been out three days as the week began
(Monday 00:00 UTC), and an urgent release at once. usemagpie.ai chooses
it from the release list (the previous commit); a release is urgent when
a line of its notes starts with "**Urgent release:**", which
magpie-releases' release run writes from an `Urgent: <why>` trailer
(magpie-releases 73f6cff).
- settings: updateChannel, "" or "stable"; anything else is refused.
- update: on Stable the feed is asked with channel=stable; What's new
shows every release since the installed one (up to 1500) instead of
the newest 40, so a week's notes read as one list.
- gui: the row is segs, never a <select>; a save that doesn't send the
channel keeps it; switching asks the feed again at once, and a
download from every version newer than Stable's pick is dropped,
never restarted into. What's new's notes are kept per channel.
- cli: magpie update channel [stable|every] ("all" too), and it says
which with nothing after it.
- docs: reference.md's Update channel (the rule and the marker); the
privacy pages (en, zh, ja) name ?channel=stable on /api/latest.
The full Go and GUI suites were not run: the disk was at 3 GB free and
other sessions had GUI suites and a 45-minute gateway run going the
whole time.
Run, at this tree before the rebase:
- gofmt -l (clean); go vet on darwin, GOOS=linux -tags nogui and
GOOS=windows for ./internal/update/... ./internal/cli/...
./internal/settings/... ./internal/gui/.
- go test -count=1 ./internal/update/... ./internal/cli/...
./internal/settings/...: ok. ./internal/gui -run
'TestUpdateChannelSwitch|TestWhatsNewKeyedByChannel|TestCoreScriptBudget':
ok (the app.js budget passes).
- GUI, chromium and webkit: update-channel (22: en, zh, zh-TW, ja, de at
900 and 420 wide: default lit, Stable saved, kept by another save,
kept over a reload, Every saved back, no click scrolls, no sideways
scroll at 420), i18n-keys, gui-ja, gui-de, gui-zh-tw and every
update-*.test.cjs: 253 of 253 pass.
- The live feed: /api/latest?channel=stable answers 0.1.1327 (out
2026-10-22 21:55 UTC, the last before Friday 10-23 00:00) with 15
assets after the first real cron run filled the ledger (400 releases
back to 10-10); /api/notes 0.1.1200..0.1.1327 gives 124 notes, none
empty (1213 and 1218 were never published).
After rebasing on afc99490f: TestCoreScriptBudget, the channel Go tests
(update, cli, gui) and GUI i18n-keys + update-channel (both engines,
26 of 26) pass again.
Broken by hand, each red: the feed asked without channel=stable
(TestLatestAsksTheChannel); Stable capped at 40 (TestStableNotesAreAll);
any channel saved (TestUpdateChannelSaved); "all" dropped
(TestUpdateChannelCmd); a save without the field clearing it, no new ask
on a switch, the newer download kept (TestUpdateChannelSwitch); one
notes key for both channels, What's new capped at 40 on Stable
(TestWhatsNewKeyedByChannel); app.js's other saves dropping the channel,
Stable's click saving "" (update-channel 11 of 11 red); the zh label or
a de subtitle taken out (update-channel and i18n-keys red).
Not tried: the full go test ./... and the whole GUI suite (above); a
real app switching channel against the live feed; Windows and Linux
runs (vet only); a real urgent release.
Requested by ssharpcc on X.
57 lines
1.8 KiB
Go
57 lines
1.8 KiB
Go
package cli
|
|
|
|
import (
|
|
"bytes"
|
|
"os"
|
|
"testing"
|
|
|
|
"github.com/yetone/magpie/internal/settings"
|
|
)
|
|
|
|
// magpie update channel stable|every saves Settings' Update channel
|
|
// (ssharpcc on X); with nothing after it, it only says which; anything
|
|
// else is refused and nothing is saved.
|
|
func TestUpdateChannelCmd(t *testing.T) {
|
|
groupsHome(t)
|
|
for _, c := range []struct {
|
|
args []string
|
|
want string
|
|
bad bool
|
|
}{
|
|
{[]string{"update", "channel"}, "", false},
|
|
{[]string{"update", "channel", "stable"}, "stable", false},
|
|
{[]string{"update", "channel"}, "stable", false},
|
|
{[]string{"update", "channel", "beta"}, "stable", true},
|
|
{[]string{"update", "channel", "stable", "every"}, "stable", true},
|
|
{[]string{"update", "channel", "every"}, "", false},
|
|
{[]string{"update", "channel", "Stable"}, "stable", false},
|
|
{[]string{"update", "channel", "all"}, "", false},
|
|
} {
|
|
err := updateCmd(c.args)
|
|
if (err != nil) != c.bad {
|
|
t.Fatalf("%v: %v", c.args, err)
|
|
}
|
|
if got := settings.Load().UpdateChannel; got != c.want {
|
|
t.Fatalf("%v: saved %q, want %q", c.args, got, c.want)
|
|
}
|
|
}
|
|
}
|
|
|
|
// A settings.json that can't be read is never written over by it.
|
|
func TestUpdateChannelKeepsCorruptSettings(t *testing.T) {
|
|
groupsHome(t)
|
|
if err := os.MkdirAll(settings.Dir(), 0o755); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
original := []byte(`{"theme":"dark","githubToken":"SYNTHETIC_PRIVATE_TOKEN"`)
|
|
if err := os.WriteFile(settings.Path(), original, 0o600); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if err := updateCmd([]string{"update", "channel", "stable"}); err == nil {
|
|
t.Error("the command reported success with corrupt settings")
|
|
}
|
|
if after, err := os.ReadFile(settings.Path()); err != nil || !bytes.Equal(after, original) {
|
|
t.Errorf("the command overwrote the corrupt settings: %v", err)
|
|
}
|
|
}
|