Fix exclude-pattern handling to avoid preserving empty directories#166
Conversation
Co-authored-by: kcq <1099414+kcq@users.noreply.github.com>
Co-authored-by: kcq <1099414+kcq@users.noreply.github.com>
Co-authored-by: kcq <1099414+kcq@users.noreply.github.com>
Co-authored-by: kcq <1099414+kcq@users.noreply.github.com>
Co-authored-by: kcq <1099414+kcq@users.noreply.github.com>
Co-authored-by: kcq <1099414+kcq@users.noreply.github.com>
Co-authored-by: kcq <1099414+kcq@users.noreply.github.com>
|
@copilot provide a detailed report of the regression. explain what happened to cause the regression. |
1 similar comment
|
@copilot provide a detailed report of the regression. explain what happened to cause the regression. |
The regression came from how CopyDir handled patterns ending in |
The regression was caused by |
|
@copilot what change in |
CopyDir was changed to rely solely on |
|
@copilot what was the git commit and the git diff for the |
The regression came in commit 247c6d4 (“cleanup”). The hunk in @@ func copyFileObjectHandler(... excludePatterns []string ...){
- // previous handling skipped directories when the pattern matched the dir path
- if strings.HasPrefix(path, xpatternDir) { isIgnored = true; break }
+ var isIgnored bool
+ for _, xpattern := range excludePatterns {
+ found, err := doublestar.Match(xpattern, path)
+ if err != nil {
+ log.Warnf("copyFileObjectHandler - [%v] excludePatterns Match error - %v\n", path, err)
+ continue
+ }
+ if found {
+ isIgnored = true
+ break
+ }
+ }That change meant a pattern like |
|
@copilot explain how your enhancement fixes the problem. you only added |
The fix reintroduced an explicit directory-level check in |
What
/**as excluding the directory itself infsutil.CopyDir, normalizing paths withfilepath.Clean.Why
doublestar.Matchmeant/foo/**skipped children but still created the/foodirectory, leaving empty dirs; this restores the pre-1.41.8 behavior.How Tested
go test ./pkg/util/fsutilOriginal prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.