fix(changelog): restore stable path aliases for #5252
changelog-filename-gate / validate (pull_request) Successful in 2s
changelog-filename-gate / validate (pull_request) Successful in 2s
这个提交包含在:
@@ -10,6 +10,7 @@ import {
|
||||
collectNewTargetPaths,
|
||||
getShanghaiDate,
|
||||
parseNameStatusZ,
|
||||
pathAliasMapFromManifest,
|
||||
runValidation,
|
||||
validateChangelogPath,
|
||||
} from '../scripts/validate-changelog-filenames.mjs';
|
||||
@@ -114,13 +115,19 @@ test('parses NUL-delimited Chinese and space-containing paths', () => {
|
||||
]);
|
||||
});
|
||||
|
||||
test('exempts modified and deleted historical bad paths', () => {
|
||||
const records = parseNameStatusZ(Buffer.from(
|
||||
'M\0changelogs-v2/2026-07/63_历史坏文件.md\0D\0changelogs-v2/2026-07/99_无issue.md\0',
|
||||
test('exempts a modified historical bad path but protects a deleted published path', () => {
|
||||
const modified = parseNameStatusZ(Buffer.from(
|
||||
'M\0changelogs-v2/2026-07/63_历史坏文件.md\0',
|
||||
'utf8',
|
||||
));
|
||||
assert.deepEqual(collectNewTargetPaths(records), []);
|
||||
assert.equal(runValidation(records, SHANGHAI_NOW).errors.length, 0);
|
||||
assert.deepEqual(collectNewTargetPaths(modified), []);
|
||||
assert.equal(runValidation(modified, SHANGHAI_NOW).errors.length, 0);
|
||||
|
||||
const deleted = parseNameStatusZ(Buffer.from(
|
||||
'D\0changelogs-v2/2026-07/99_无issue.md\0',
|
||||
'utf8',
|
||||
));
|
||||
assert.ok(runValidation(deleted, SHANGHAI_NOW).errors.some(({ code }) => code === 'E_PATH_STABILITY'));
|
||||
});
|
||||
|
||||
test('validates only a copy target path', () => {
|
||||
@@ -128,9 +135,23 @@ test('validates only a copy target path', () => {
|
||||
assert.deepEqual(collectNewTargetPaths(records), [validAdmin()]);
|
||||
});
|
||||
|
||||
test('accepts a rename from an old bad name to a valid target', () => {
|
||||
const records = parseNameStatusZ(Buffer.from(`R100\0changelogs-v2/2026-07/63_old.md\0${validAdmin()}\0`, 'utf8'));
|
||||
assert.equal(runValidation(records, SHANGHAI_NOW).errors.length, 0);
|
||||
test('rejects a rename without a machine-readable compatibility alias', () => {
|
||||
const source = 'changelogs-v2/2026-07/63_old.md';
|
||||
const records = parseNameStatusZ(Buffer.from(`R100\0${source}\0${validAdmin()}\0`, 'utf8'));
|
||||
assert.ok(runValidation(records, SHANGHAI_NOW).errors.some(({ code }) => code === 'E_PATH_STABILITY'));
|
||||
});
|
||||
|
||||
test('accepts a rename and a legacy alias path when both are registered', () => {
|
||||
const source = 'changelogs-v2/2026-07/63_old.md';
|
||||
const target = validAdmin();
|
||||
const pathAliases = pathAliasMapFromManifest({
|
||||
schema: 'hl-changelog-path-aliases/v1',
|
||||
aliases: [{ alias: source, canonical: target }],
|
||||
});
|
||||
const rename = parseNameStatusZ(Buffer.from(`R100\0${source}\0${target}\0`, 'utf8'));
|
||||
assert.equal(runValidation(rename, SHANGHAI_NOW, { pathAliases }).errors.length, 0);
|
||||
const compatibilityAddition = parseNameStatusZ(Buffer.from(`A\0${source}\0`, 'utf8'));
|
||||
assert.equal(runValidation(compatibilityAddition, SHANGHAI_NOW, { pathAliases }).errors.length, 0);
|
||||
});
|
||||
|
||||
test('rejects a rename target with an old day', () => {
|
||||
|
||||
在新工单中引用
屏蔽一个用户