mirror of
https://github.com/morluto/rea.git
synced 2026-11-19 13:12:26 +00:00
fix(ci): preserve line breaks in Git blob paths (#12227)
This commit is contained in:
1 parent
1a89383a79
commit
fedf33eb59
2 files changed
+21
-3
No files matched your search
@@ -450,11 +450,11 @@ export const gitRepository = (cwd = process.cwd()) => {
|
||||
git("ls-tree", "-r", "-z", "--name-only", revision, "--", ...directories)
|
||||
.split("\0")
|
||||
.filter(Boolean),
|
||||
// One batch process reads every requested blob.
|
||||
// NUL-terminate requests so a line break in a path remains part of its name.
|
||||
readFiles: (revision, paths) => {
|
||||
const output = execFileSync("git", ["cat-file", "--batch"], {
|
||||
const output = execFileSync("git", ["cat-file", "--batch", "-z"], {
|
||||
cwd,
|
||||
input: paths.map((path) => `${revision}:${path}\n`).join(""),
|
||||
input: paths.map((path) => `${revision}:${path}\0`).join(""),
|
||||
maxBuffer: 512 * 1024 * 1024,
|
||||
});
|
||||
const contents = new Map();
|
||||
|
||||
@@ -2275,3 +2275,21 @@ it.each([
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
it("reads a Git blob whose path contains a line break alongside an ordinary blob", async ({
|
||||
skip,
|
||||
}) => {
|
||||
skip(
|
||||
process.platform === "win32",
|
||||
"Windows paths cannot contain line breaks",
|
||||
);
|
||||
const { directory } = await fixture();
|
||||
const path = "src/two\nlines.test.ts";
|
||||
const head = await change(directory, [path], "multiline path\n");
|
||||
expect(gitRepository(directory).readFiles(head, [path, "README.md"])).toEqual(
|
||||
new Map([
|
||||
[path, "multiline path\n"],
|
||||
["README.md", "Initial fixture content\n"],
|
||||
]),
|
||||
);
|
||||
});
|
||||
Reference in new issue
Block a user