diff --git a/scripts/check-changelog-semver.mjs b/scripts/check-changelog-semver.mjs index ea3cecd3..c11fcd2e 100644 --- a/scripts/check-changelog-semver.mjs +++ b/scripts/check-changelog-semver.mjs @@ -239,15 +239,14 @@ function resolveRelease(tagPrefix, versionText, cwd, folder) { // The first of the tags that tracks any file under `folder`, or none. A tag that cannot be read // is a refusal, never a tag that tracks nothing. function firstTagTracking(tags, folder, cwd) { - const pathspec = folder === "." ? [] : ["--", `${folder}/`]; for (const tag of tags) { try { - const listing = execFileSync("git", ["ls-tree", "-r", "--name-only", `refs/tags/${tag}`, ...pathspec], { + const listing = execFileSync("git", ["ls-tree", "-r", "--name-only", `refs/tags/${tag}`, "--", `${folder}/`], { cwd, encoding: "utf8", stdio: ["ignore", "pipe", "ignore"], }); - if (listing.trim() !== "") return { tag }; + if (listing !== "") return { tag }; } catch { return { failure: `the files ${tag} tracks under ${folder} could not be read, so a first release cannot be told from a mistyped prefix` }; } diff --git a/scripts/check-changelog-semver.test.mjs b/scripts/check-changelog-semver.test.mjs index 6542efe5..f7669d0d 100644 --- a/scripts/check-changelog-semver.test.mjs +++ b/scripts/check-changelog-semver.test.mjs @@ -508,7 +508,9 @@ test("CLI: a tag that cannot be read at its ancestry or its files refuses", () = commitAndTag(dir, "other-v1.0.0"); writeFileSync(join(dir, ".git", "refs", "tags", "other-v2.0.0"), "1".repeat(40) + "\n"); writeChangelog(dir, "1.0.0"); - assert.match(runCheckerExpectFailure(dir, widgetArgs("1.0.0")), /could not be read, so a first release cannot be told from a mistyped prefix/); + const refused = runCheckerExpectFailure(dir, widgetArgs("1.0.0")); + assert.match(refused, /could not be read, so a first release cannot be told from a mistyped prefix/); + assert.doesNotMatch(refused, /fatal|bad object|1111111/); // git's own complaint is not forwarded }); });