-
Notifications
You must be signed in to change notification settings - Fork 262
fix(amazonq): update logic for converting gitignore pattern to regex #5360
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -161,4 +161,49 @@ class FeatureDevSessionContextTest : FeatureDevTestBase(HeavyJavaCodeInsightTest | |
|
||
assertEquals(zippedFiles, expectedFiles) | ||
} | ||
|
||
@Test | ||
fun testConvertGitIgnorePatternToRegex() { | ||
val sampleGitIgnorePatterns = listOf(".*", "build/", "*.txt", "*.png") | ||
val sampleFileNames = listOf( | ||
".gitignore/", | ||
".env/", | ||
"file.txt/", | ||
".git/config/", | ||
"src/file.txt/", | ||
gandhi-21 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"build/", | ||
"build/output.jar/", | ||
"builds/", | ||
"mybuild/", | ||
"build.json/", | ||
"log.txt/", | ||
"file.txt.json/", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why each file name ends with '/' ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. there's a trailing / added when matching files as per the comment |
||
"file.png/", | ||
"src/file.png/" | ||
) | ||
|
||
val patterns = sampleGitIgnorePatterns.map { pattern -> featureDevSessionContext.convertGitIgnorePatternToRegex(pattern).toRegex() } | ||
|
||
val matchedFiles = sampleFileNames.filter { fileName -> | ||
patterns.any { pattern -> | ||
pattern.matches(fileName) | ||
} | ||
} | ||
|
||
val expectedFilesToMatch = | ||
listOf( | ||
".gitignore/", | ||
".env/", | ||
"file.txt/", | ||
".git/config/", | ||
"src/file.txt/", | ||
"build/", | ||
"build/output.jar/", | ||
"log.txt/", | ||
"file.png/", | ||
"src/file.png/" | ||
) | ||
|
||
assertEquals(expectedFilesToMatch, matchedFiles) | ||
} | ||
} |
Uh oh!
There was an error while loading. Please reload this page.