Skip to content

armgit / mso

Public Imported from GitHub
0

Browser-based graphical shell and control plane for a Linux server you own — real terminal, file manager, live metrics and BYOK AI in one mobile-first workspace. Next.js 16 · React 19 · node-pty · Tailwind v4 · shadcn/ui. Public alpha, self-hosted.

fix(changelog): make the file independent of when it was regenerated

Abdurrahman Fakhrulaaffc6879789
diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md
index ab678d59..3d0b7136 100644
--- a/docs/CHANGELOG.md
+++ b/docs/CHANGELOG.md
@@ -8,7 +8,7 @@ this is the *what*, and it is what Settings → Account → About shows as “Wh
**Added**
-- `tui` restore the three modules #249 dropped, with their wiring
+- `tui` restore the three modules #249 dropped, with their wiring (#256)
- `tui` opencode batch two, six capabilities and five honest refusals (#249)
- `tui` the opencode-inspired batch, nine branches in one change (#241)
- `tui` pin a pane slot without losing the cycle (#229)
@@ -148,7 +148,6 @@ this is the *what*, and it is what Settings → Account → About shows as “Wh
- `shell, gates` restore the artwork reveal rule, and make the instance guard actually read files (#171)
- `install` make bun install compile node-pty without a global node-gyp
- `api` restore the models provider name the route extraction dropped (#169)
-- `api` restore the models provider name the route extraction dropped (#168)
- `build` restore the turbopackIgnore annotation the route extraction dropped
**Faster**
diff --git a/scripts/changelog-gate.test.ts b/scripts/changelog-gate.test.ts
index 263d271f..087e69ad 100644
--- a/scripts/changelog-gate.test.ts
+++ b/scripts/changelog-gate.test.ts
@@ -122,4 +122,39 @@ describe("changelog staleness gate", () => {
// And the gate must pass afterwards, which is the actual defect being fixed.
expect(spawnSync(process.execPath, ["scripts/gen-changelog.mjs", "--check"], { cwd: root, encoding: "utf8" }).status).toBe(0);
});
+
+ // The subject a squash writes is not the subject the branch had, so the file used to depend on
+ // WHEN it was regenerated. Seen as a CI-only failure: local passed while GitHub's PR merge ref,
+ // which includes the squash commit, reported stale.
+ it("is stable whether or not a subject carries its squash PR number", () => {
+ const root = mkdtempSync(path.join(os.tmpdir(), "mso-changelog-suffix-"));
+ roots.push(root);
+ mkdirSync(path.join(root, "scripts"), { recursive: true });
+ mkdirSync(path.join(root, "docs"), { recursive: true });
+ writeFileSync(path.join(root, "scripts/gen-changelog.mjs"), readFileSync(path.join(ROOT, "scripts/gen-changelog.mjs")));
+
+ const git = (...args: string[]) => spawnSync("git", args, { cwd: root, encoding: "utf8" });
+ const commit = (file: string, subject: string) => {
+ writeFileSync(path.join(root, file), file);
+ git("-c", "user.name=T", "-c", "[email protected]", "add", "-A");
+ git("-c", "user.name=T", "-c", "[email protected]", "commit", "-qm", subject);
+ };
+ git("init", "-q");
+ commit("a.txt", "feat(x): a change that will be squashed");
+
+ const gen = () => spawnSync(process.execPath, ["scripts/gen-changelog.mjs"], { cwd: root, encoding: "utf8" });
+ const check = () => spawnSync(process.execPath, ["scripts/gen-changelog.mjs", "--check"], { cwd: root, encoding: "utf8" }).status;
+
+ expect(gen().status).toBe(0);
+ const before = readFileSync(path.join(root, "docs/CHANGELOG.md"), "utf8");
+ expect(before).toContain("a change that will be squashed");
+ expect(check(), "current right after generating").toBe(0);
+
+ // Now the same change gains its squash number, exactly as a PR merge ref would see it.
+ commit("b.txt", "feat(x): a change that will be squashed (#4242)");
+ expect(check(), "adding the squash suffix must not invalidate the file").toBe(0);
+ expect(gen().status).toBe(0);
+ const after = readFileSync(path.join(root, "docs/CHANGELOG.md"), "utf8");
+ expect(after.match(/a change that will be squashed/g)?.length, "still one row").toBe(1);
+ });
});
diff --git a/scripts/gen-changelog.mjs b/scripts/gen-changelog.mjs
index 82e3aa22..6e50aef4 100644
--- a/scripts/gen-changelog.mjs
+++ b/scripts/gen-changelog.mjs
@@ -94,23 +94,29 @@ for (const [date, list] of byDay) {
);
}
-// A squash merge appends " (#NNN)" to the subject, so the same change can appear twice
-// on one day: once as the original commits, once as the squashed commit that replaced
-// them. The bare number tells the reader nothing the line does not already say, so when
-// a subject with a PR number collides with the same subject without one, keep the bare
-// form. Only collisions are touched — a PR number that is the only occurrence survives,
-// because it is the one fact linking a line to its discussion.
+// A squash merge appends " (#NNN)" to the subject it replaces. That makes the generated
+// file depend on WHEN it was regenerated rather than on what the code says: a branch
+// regenerated before its own squash lists a bare subject, and the same branch after the
+// squash lists the suffixed one. Observed as a CI-only failure — the local tree passed
+// while GitHub's PR merge ref, which includes the squash, reported the file stale.
+//
+// So the PR suffix is stripped for comparison purposes: two rows whose subjects differ only
+// by " (#NNN)" are the same change. The bare form is kept, because the number adds nothing a
+// reader cannot get from git log.
+const stripPrSuffix = (s) => s.replace(/\s*\(#\d+\)\s*$/, "");
for (const [date, list] of byDay) {
- const bare = new Set(list.filter((c) => !/\(#\d+\)$/.test(c.subject)).map((c) => c.subject));
- const hasPrSuffix = (s) => /^(.*\S)\s+\(#\d+\)$/.exec(s);
- byDay.set(
- date,
- list.filter((c) => {
- const m = hasPrSuffix(c.subject);
- // Keep the suffixed row only when nothing bare describes the same change.
- return !(m && bare.has(m[1]));
- }),
- );
+ // Group by the suffix-free subject, then emit one row per change. The bare form wins when both
+ // exist, so the file does not flip depending on whether it was regenerated before or after the
+ // squash that added the number.
+ const groups = new Map();
+ for (const row of list) {
+ const key = stripPrSuffix(row.subject);
+ const kept = groups.get(key);
+ if (!kept) groups.set(key, row);
+ else if (stripPrSuffix(kept.subject) !== kept.subject && stripPrSuffix(row.subject) === row.subject)
+ groups.set(key, row);
+ }
+ byDay.set(date, [...groups.values()]);
}
const days = [...byDay.keys()].sort().reverse().slice(0, MAX_DAYS);