Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 7, 2025

Problem

The parseInputFiles function was using a naive split(',') to parse comma-delimited file patterns, which broke valid glob patterns containing commas inside brace groups.

For example, a common glob pattern like:

files: |
  ./**/*.{exe,deb,tar.gz}

Would incorrectly be split into three separate invalid patterns:

['./**/*.{exe', 'deb', 'tar.gz}']

This caused the glob matching to fail since the patterns were malformed.

Solution

Implemented a smartSplit() helper function that:

  • Tracks brace depth while iterating through each character
  • Only splits on commas when outside of braces (braceDepth === 0)
  • Preserves commas inside brace groups as part of the pattern
  • Trims whitespace from each result

Updated parseInputFiles() to:

  • Split lines by newlines (unchanged behavior)
  • Use smartSplit() instead of naive String.split(',')
  • Use flatMap() for cleaner code structure

Examples

Now Works Correctly

parseInputFiles('./**/*.{exe,deb,tar.gz}')
// → ['./**/*.{exe,deb,tar.gz}']  ✅

parseInputFiles('./**/*.{exe,deb,tar.gz}\nfoo,bar')
// → ['./**/*.{exe,deb,tar.gz}', 'foo', 'bar']  ✅

Backward Compatibility Maintained

parseInputFiles('foo,bar')
// → ['foo', 'bar']  ✅

parseInputFiles('foo\nbar\nbaz')
// → ['foo', 'bar', 'baz']  ✅

parseInputFiles('foo,bar\nbaz,boom')
// → ['foo', 'bar', 'baz', 'boom']  ✅

Testing

Added comprehensive test coverage including:

  • Glob patterns with brace groups containing commas
  • Multiple brace groups on the same line
  • Nested braces (e.g., path/{a,{b,c}}/file.txt)
  • Mixed newlines and commas with braces
  • Empty comma-separated values
  • Whitespace handling

All 44 tests pass (7 new tests added), including all existing tests to ensure backward compatibility.

Fixes #659

Original prompt

This section details on the original issue you should resolve

<issue_title>files not support glob match files: '.**/*.{exe,deb,tar.gz}'</issue_title>
<issue_description>I find , will split ,but glob allow '.**/*.{exe,deb,tar.gz}' match

.concat(line.split(','))
</issue_description>

<agent_instructions>Fix the bug described in issue #659 – “files not support glob match files: './*.{exe,deb,tar.gz}'”**.

Problem

Currently, parseInputFiles in src/util.ts splits on commas (line.split(',')), which breaks valid glob patterns containing commas inside {} groups like:

files: |
./**/*.{exe,deb,tar.gz}

This causes the string to be split into invalid patterns ('.**/*.{exe', 'deb', 'tar.gz}').

Required Fix

Modify parseInputFiles so that it:

Still supports newline-delimited and comma-delimited lists for separate patterns.

Ignores commas inside {} groups when splitting (so .**/*.{exe,deb,tar.gz} remains one pattern).

Example expected behavior:

parseInputFiles('./*.{exe,deb,tar.gz}\nfoo,bar')
// → ['.
/*.{exe,deb,tar.gz}', 'foo', 'bar']

Implementation hint

A simple way:

Use a small parser that tracks brace depth while splitting on commas.

Only split when comma appears outside braces.

Example algorithm (you can refine it):

function 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) {
result.push(current.trim());
current = '';
} else {
current += ch;
}
}
if (current.trim()) result.push(current.trim());
return result;
}

Then in parseInputFiles:

export const parseInputFiles = (files: string): string[] => {
return files
.split(/\r?\n/)
.flatMap((line) => smartSplit(line))
.filter((pat) => pat.trim() !== '');
};

Tests

Add unit tests in tests/util.test.ts:

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}',
]);
});

Validation

After implementation:

Run npm test to ensure new and existing tests pass.

Commit with:

fix(util): support brace expansion globs containing commas in parseInputFiles
test(util): add coverage for brace expansion glob parsing</agent_instructions>

Comments on the Issue (you are @copilot in this section)

Fixes #659

💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Copilot AI changed the title [WIP] files not support glob match files: '.**/*.{exe,deb,tar.gz}' fix(util): support brace expansion globs containing commas in parseInputFiles Oct 7, 2025
Copilot AI requested a review from chenrui333 October 7, 2025 03:25
Copilot finished work on behalf of chenrui333 October 7, 2025 03:25
@chenrui333 chenrui333 marked this pull request as ready for review October 7, 2025 03:49
@chenrui333 chenrui333 merged commit cec1a11 into master Oct 7, 2025
3 checks passed
@chenrui333 chenrui333 deleted the copilot/fix-476a4a90-d616-4c23-8615-6a8e7be7f73e branch October 7, 2025 03:50
@chenrui333 chenrui333 added the bug Something isn't working label Oct 11, 2025
mergify bot added a commit to robfrank/linklift that referenced this pull request Oct 15, 2025
Bumps the github-actions group with 2 updates: [softprops/action-gh-release](https://github.com/softprops/action-gh-release) and [ruby/setup-ruby](https://github.com/ruby/setup-ruby).
Updates `softprops/action-gh-release` from 2.3.4 to 2.4.1
Release notes

*Sourced from [softprops/action-gh-release's releases](https://github.com/softprops/action-gh-release/releases).*

> v2.4.1
> ------
>
> What's Changed
> --------------
>
> ### Other Changes 🔄
>
> * fix(util): support brace expansion globs containing commas in parseInputFiles by [`@​Copilot`](https://github.com/Copilot) in [softprops/action-gh-release#672](https://redirect.github.com/softprops/action-gh-release/pull/672)
> * fix: gracefully fallback to body when body\_path cannot be read by [`@​Copilot`](https://github.com/Copilot) in [softprops/action-gh-release#671](https://redirect.github.com/softprops/action-gh-release/pull/671)
>
> **Full Changelog**: <softprops/action-gh-release@v2...v2.4.1>
>
> v2.4.0
> ------
>
> What's Changed
> --------------
>
> ### Exciting New Features 🎉
>
> * feat(action): respect working\_directory for files globs by [`@​stephenway`](https://github.com/stephenway) in [softprops/action-gh-release#667](https://redirect.github.com/softprops/action-gh-release/pull/667)
>
> ### Other Changes 🔄
>
> * chore(deps): bump the npm group with 2 updates by [`@​dependabot`](https://github.com/dependabot)[bot] in [softprops/action-gh-release#668](https://redirect.github.com/softprops/action-gh-release/pull/668)
>
> **Full Changelog**: <softprops/action-gh-release@v2.3.4...v2.4.0>


Changelog

*Sourced from [softprops/action-gh-release's changelog](https://github.com/softprops/action-gh-release/blob/master/CHANGELOG.md).*

> 2.4.1
> -----
>
> What's Changed
> --------------
>
> ### Other Changes 🔄
>
> * fix(util): support brace expansion globs containing commas in parseInputFiles by [`@​Copilot`](https://github.com/Copilot) in [softprops/action-gh-release#672](https://redirect.github.com/softprops/action-gh-release/pull/672)
> * fix: gracefully fallback to body when body\_path cannot be read by [`@​Copilot`](https://github.com/Copilot) in [softprops/action-gh-release#671](https://redirect.github.com/softprops/action-gh-release/pull/671)
>
> 2.4.0
> -----
>
> What's Changed
> --------------
>
> ### Exciting New Features 🎉
>
> * feat(action): respect working\_directory for files globs by [`@​stephenway`](https://github.com/stephenway) in [softprops/action-gh-release#667](https://redirect.github.com/softprops/action-gh-release/pull/667)
>
> 2.3.4
> -----
>
> What's Changed
> --------------
>
> ### Bug fixes 🐛
>
> * fix(action): handle 422 already\_exists race condition by [`@​stephenway`](https://github.com/stephenway) in [softprops/action-gh-release#665](https://redirect.github.com/softprops/action-gh-release/pull/665)
>
> ### Other Changes 🔄
>
> * dependency updates
>
> 2.3.3
> -----
>
> What's Changed
> --------------
>
> ### Exciting New Features 🎉
>
> * feat: add input option `overwrite_files` by [`@​asfernandes`](https://github.com/asfernandes) in [softprops/action-gh-release#343](https://redirect.github.com/softprops/action-gh-release/pull/343)
>
> ### Other Changes 🔄
>
> * dependency updates
>
> 2.3.2
> -----
>
> * fix: revert fs `readableWebStream` change
>
> 2.3.1
> -----
>
> ### Bug fixes 🐛
>
> * fix: fix file closing issue by [`@​WailGree`](https://github.com/WailGree) in [softprops/action-gh-release#629](https://redirect.github.com/softprops/action-gh-release/pull/629)

... (truncated)


Commits

* [`6da8fa9`](softprops/action-gh-release@6da8fa9) release 2.4.1
* [`f38efde`](softprops/action-gh-release@f38efde) fix: gracefully fallback to body when body\_path cannot be read ([#671](https://redirect.github.com/softprops/action-gh-release/issues/671))
* [`cec1a11`](softprops/action-gh-release@cec1a11) fix(util): support brace expansion globs containing commas in parseInputFiles...
* [`aec2ec5`](softprops/action-gh-release@aec2ec5) release 2.4.0
* [`4db716b`](softprops/action-gh-release@4db716b) feat: respect working\_directory for files globs; add input and tests ([#667](https://redirect.github.com/softprops/action-gh-release/issues/667))
* [`14820f2`](softprops/action-gh-release@14820f2) chore(deps): bump the npm group with 2 updates ([#668](https://redirect.github.com/softprops/action-gh-release/issues/668))
* See full diff in [compare view](softprops/action-gh-release@62c96d0...6da8fa9)
  
Updates `ruby/setup-ruby` from 1.263.0 to 1.265.0
Release notes

*Sourced from [ruby/setup-ruby's releases](https://github.com/ruby/setup-ruby/releases).*

> v1.265.0
> --------
>
> What's Changed
> --------------
>
> * Update CRuby releases on Windows by [`@​ruby-builder-bot`](https://github.com/ruby-builder-bot) in [ruby/setup-ruby#817](https://redirect.github.com/ruby/setup-ruby/pull/817)
>
> **Full Changelog**: <ruby/setup-ruby@v1.264.0...v1.265.0>
>
> v1.264.0
> --------
>
> What's Changed
> --------------
>
> * Add ruby-3.4.7 by [`@​ruby-builder-bot`](https://github.com/ruby-builder-bot) in [ruby/setup-ruby#815](https://redirect.github.com/ruby/setup-ruby/pull/815)
>
> **Full Changelog**: <ruby/setup-ruby@v1.263.0...v1.264.0>


Commits

* [`ab177d4`](ruby/setup-ruby@ab177d4) Update CRuby releases on Windows
* [`6797dcb`](ruby/setup-ruby@6797dcb) Add ruby-3.4.7
* [`a16e0e6`](ruby/setup-ruby@a16e0e6) Test on macos-15-intel too
* See full diff in [compare view](ruby/setup-ruby@0481980...ab177d4)
  
Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.
[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)
---
Dependabot commands and options
  
You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot show  ignore conditions` will show all of the ignore conditions of the specified dependency
- `@dependabot ignore  major version` will close this group update PR and stop Dependabot creating any more for the specific dependency's major version (unless you unignore this specific dependency's major version or upgrade to it yourself)
- `@dependabot ignore  minor version` will close this group update PR and stop Dependabot creating any more for the specific dependency's minor version (unless you unignore this specific dependency's minor version or upgrade to it yourself)
- `@dependabot ignore ` will close this group update PR and stop Dependabot creating any more for the specific dependency (unless you unignore this specific dependency or upgrade to it yourself)
- `@dependabot unignore ` will remove all of the ignore conditions of the specified dependency
- `@dependabot unignore  ` will remove the ignore condition of the specified dependency and ignore conditions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

files not support glob match files: '.**/*.{exe,deb,tar.gz}'

2 participants