fix(util): support brace expansion globs containing commas in parseInputFiles

Co-authored-by: chenrui333 <1580956+chenrui333@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot] 2025-10-07 03:19:33 +00:00
parent 1706253de1
commit c619af70ff
3 changed files with 44 additions and 9 deletions

View file

@ -39,6 +39,18 @@ describe('util', () => {
'loom', 'loom',
]); ]);
}); });
it('handles globs with brace groups containing commas', () => {
assert.deepStrictEqual(parseInputFiles('./**/*.{exe,deb,tar.gz}\nfoo,bar'), [
'./**/*.{exe,deb,tar.gz}',
'foo',
'bar',
]);
});
it('handles single-line brace pattern correctly', () => {
assert.deepStrictEqual(parseInputFiles('./**/*.{exe,deb,tar.gz}'), [
'./**/*.{exe,deb,tar.gz}',
]);
});
}); });
describe('releaseBody', () => { describe('releaseBody', () => {
it('uses input body', () => { it('uses input body', () => {

2
dist/index.js vendored

File diff suppressed because one or more lines are too long

View file

@ -43,15 +43,38 @@ export const releaseBody = (config: Config): string | undefined => {
type Env = { [key: string]: string | undefined }; type Env = { [key: string]: string | undefined };
const smartSplit = (input: string): string[] => {
const result: string[] = [];
let current = '';
let braceDepth = 0;
for (const ch of input) {
if (ch === '{') {
braceDepth++;
}
if (ch === '}') {
braceDepth--;
}
if (ch === ',' && braceDepth === 0) {
if (current.trim()) {
result.push(current.trim());
}
current = '';
} else {
current += ch;
}
}
if (current.trim()) {
result.push(current.trim());
}
return result;
};
export const parseInputFiles = (files: string): string[] => { export const parseInputFiles = (files: string): string[] => {
return files.split(/\r?\n/).reduce<string[]>( return files
(acc, line) => .split(/\r?\n/)
acc .flatMap((line) => smartSplit(line))
.concat(line.split(',')) .filter((pat) => pat.trim() !== '');
.filter((pat) => pat)
.map((pat) => pat.trim()),
[],
);
}; };
export const parseConfig = (env: Env): Config => { export const parseConfig = (env: Env): Config => {