Files
msd-core/tests/execute-phase-branch-base-ahead-warning.test.cjs
Jakub Zych a9a7a328e6 refactor: hard-fork GSD -> MSD (Make Software Done)
Mechanical rename produced by scripts/msd-rename.cjs: gsd/Gsd/GSD -> msd/Msd/MSD
across contents and paths, upstream package/repo coordinates -> @golem15/msd-core
and golem15com/msd-core. Deep links into upstream history, sibling upstream
packages, the GSD-2 import feature, CHANGELOG.md and .changeset/ are kept as-is.

Hand edits on top: MSD block-letter banner and logos, LICENSE copyright line,
package/plugin identity, regenerated lockfile, install-tree fixtures, derived
registries and benchmark baseline; migration checksum baseline re-locked
(MSD keeps its own install state, so no install had applied the old sums);
sort-order and regex-escaped expectations in tests adjusted.
2026-10-06 01:47:40 +02:00

38 lines
1.7 KiB
JavaScript

// allow-test-rule: source-text-is-the-product (see #2639)
// msd-core/workflows/execute-phase.md is the deployed CI contract; asserting
// that handle_branching warns when local is ahead of origin is only expressible
// against the workflow text.
'use strict';
const { describe, test } = require('node:test');
const assert = require('node:assert/strict');
const fs = require('node:fs');
const path = require('node:path');
const WORKFLOW = path.join(__dirname, '..', 'msd-core', 'workflows', 'execute-phase.md');
describe('#2639 — handle_branching warns when local is ahead of origin', () => {
const text = fs.existsSync(WORKFLOW) ? fs.readFileSync(WORKFLOW, 'utf8') : '';
test('the fork block checks for local-ahead-of-origin before branching', () => {
assert.ok(text.length > 0, 'execute-phase.md must exist');
// The fix adds a `git rev-list --count origin/$DEFAULT_BRANCH..$DEFAULT_BRANCH`
// check before the `git checkout -b` fork, with a WARNING to stderr.
assert.ok(
/rev-list.*--count.*DEFAULT_BRANCH/i.test(text),
'handle_branching must check if local $DEFAULT_BRANCH is ahead of origin before forking (git rev-list --count) — without this, unpushed local commits are silently missing from the phase branch (#2639)',
);
});
test('the warning names the divergence and advises the user', () => {
assert.ok(text.length > 0, 'execute-phase.md must exist');
// The warning must mention "ahead" and "unpushed" so the user understands
// their commits won't be on the phase branch.
assert.ok(
/ahead.*origin.*DEFAULT_BRANCH/i.test(text) || /unpushed/i.test(text),
'handle_branching must warn that local commits are ahead/unpushed when forking from origin (#2639)',
);
});
});