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

* Initial plan

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

Co-authored-by: chenrui333 <1580956+chenrui333@users.noreply.github.com>

* test(util): add comprehensive edge case coverage for brace expansion parsing

Co-authored-by: chenrui333 <1580956+chenrui333@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: chenrui333 <1580956+chenrui333@users.noreply.github.com>
This commit is contained in:
Copilot 2025-10-06 23:50:00 -04:00 committed by GitHub
parent aec2ec56f9
commit cec1a1113b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 77 additions and 9 deletions

View file

@ -43,15 +43,38 @@ export const releaseBody = (config: Config): 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[] => {
return files.split(/\r?\n/).reduce<string[]>(
(acc, line) =>
acc
.concat(line.split(','))
.filter((pat) => pat)
.map((pat) => pat.trim()),
[],
);
return files
.split(/\r?\n/)
.flatMap((line) => smartSplit(line))
.filter((pat) => pat.trim() !== '');
};
export const parseConfig = (env: Env): Config => {