Skip to content

fix: files filter with #991

Open
yevheniyJ wants to merge 1 commit intomainfrom
fix-file-filter-context-management
Open

fix: files filter with #991
yevheniyJ wants to merge 1 commit intomainfrom
fix-file-filter-context-management

Conversation

@yevheniyJ
Copy link
Collaborator

No description provided.

@yevheniyJ yevheniyJ marked this pull request as ready for review February 23, 2026 17:52
@codecov
Copy link

codecov bot commented Feb 23, 2026

Codecov Report

❌ Patch coverage is 70.96774% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 65.30%. Comparing base (e17a953) to head (c51babc).

Files with missing lines Patch % Lines
...com/crowdin/cli/properties/helper/FileMatcher.java 68.97% 4 Missing and 5 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main     #991      +/-   ##
============================================
+ Coverage     65.29%   65.30%   +0.02%     
- Complexity     1763     1771       +8     
============================================
  Files           255      255              
  Lines          7285     7314      +29     
  Branches       1101     1109       +8     
============================================
+ Hits           4756     4776      +20     
- Misses         1890     1894       +4     
- Partials        639      644       +5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request fixes file filtering to properly handle file paths containing literal square brackets (like [test.Folder dev]) versus glob character class patterns (like [a-z] or [0-9]). The fix distinguishes between these two cases by analyzing bracket content and escaping those that contain special characters like spaces and dots, while preserving valid character class patterns for glob matching.

Changes:

  • Added bracket escaping logic in FileMatcher to distinguish literal brackets from glob character classes
  • Updated path normalization in FileHelper.isPathMatch to ensure both paths and patterns start with a separator for consistent matching
  • Added tests to verify the fix handles paths with literal brackets and character class patterns correctly

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
src/main/java/com/crowdin/cli/properties/helper/FileMatcher.java Added escapeInvalidBrackets and isValidCharacterClass methods to intelligently escape square brackets that are not part of valid glob character class patterns
src/main/java/com/crowdin/cli/properties/helper/FileHelper.java Updated isPathMatch to normalize both path and pattern with leading separators for consistent matching behavior
src/test/java/com/crowdin/cli/properties/helper/FileHelperTest.java Added test cases to verify matching works with literal brackets and character class patterns, including cross-matching with/without leading slashes
src/test/java/com/crowdin/cli/commands/actions/ContextDownloadActionTest.java Added comprehensive test case testJsonlSavesFileFilter2 to verify file filtering works with paths containing literal brackets like [test.Folder dev]

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

}

@Test
public void testJsonlSavesFileFilter2() throws Exception {
Copy link

Copilot AI Feb 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test method name testJsonlSavesFileFilter2 is not descriptive. It should clearly indicate what specific scenario is being tested. Consider renaming it to something like testJsonlSavesFileFilterWithBracketsInFolderNames or testJsonlSavesFileFilterWithSpecialCharactersInPath to make the test's purpose immediately clear.

Suggested change
public void testJsonlSavesFileFilter2() throws Exception {
public void testJsonlSavesFileFilterWithBracketsInFolderNames() throws Exception {

Copilot uses AI. Check for mistakes.
public void testJsonlSavesFileFilter2() throws Exception {
ProjectProperties pb = NewProjectPropertiesUtilBuilder.minimalBuilt().build();

// Build project with one file (id=101)
Copy link

Copilot AI Feb 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment states "Build project with one file (id=101)" but the code actually adds two files with ids 101 and 102. Update the comment to accurately reflect the test setup, for example: "Build project with two files (id=101 and id=102)".

Suggested change
// Build project with one file (id=101)
// Build project with two files (id=101 and id=102)

Copilot uses AI. Check for mistakes.

SourceString ss2 = SourceStringBuilder.standard()
.setProjectId(Long.parseLong(pb.getProjectId()))
.setIdentifiers(702L, "the-text2", "manual\n\n✨ AI Context\nai-content2\n✨ 🔚", "the.key2", 101L)
Copy link

Copilot AI Feb 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The source string ss2 is created with fileId=101L (the last parameter in setIdentifiers), but it's being returned by the mock when querying for source strings from file 102L. This is inconsistent.

Since the test is checking that both files (101 and 102) are processed when matching the filter /[test.Folder dev]/**/*.php, the source strings should have the correct fileId to reflect which file they belong to. Update ss2 to use fileId=102L instead of 101L.

Suggested change
.setIdentifiers(702L, "the-text2", "manual\n\n✨ AI Context\nai-content2\n✨ 🔚", "the.key2", 101L)
.setIdentifiers(702L, "the-text2", "manual\n\n✨ AI Context\nai-content2\n✨ 🔚", "the.key2", 102L)

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants