Semver check: the folder pathspec has no root special case and the tree listing is compared as git prints it
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
a8a6d1bf85
commit
e940a37316
2 changed files with 5 additions and 4 deletions
|
|
@ -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` };
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue