fix(parse): preserve filters for local git repositories - #3190
Merged
qin-ctx merged 1 commit intoJul 13, 2026
Merged
Conversation
Collaborator
Author
|
@qin-ctx @MaojiaSheng could you please review this focused fix when convenient? It fixes #3187: local Git repositories silently dropped |
qin-ctx
approved these changes
Jul 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
动机
修复 #3187。
DirectoryParser识别到本地 Git 仓库后,会把ignore_dirs、include和exclude传给CodeRepositoryParser,但后者在调用共享目录上传逻辑前丢失了这三个参数。因此,同一个本地目录仅因存在.git/,就会生成不同的资源树;watch 刷新也会重复这一不一致行为。改动思路
复用普通目录扫描器已有的过滤语义,而不是为 Git 仓库定义第二套过滤语言:让
CodeRepositoryParser将三个过滤参数完整传到共享 uploader,再由 uploader 统一组合内置忽略目录、.gitignore、include/exclude glob、扩展名和文件大小限制。关键调用链 / 伪代码
watch task 已经把这些参数保存在
processor_kwargs,因此后续刷新会自动走修复后的同一路径。具体改动
CodeRepositoryParser继续传递ignore_dirs、include和exclude;DirectoryParser的 path/glob 过滤语义;.gitignore、忽略扩展名、文件大小限制和并发上传行为不变。修复后复现
可以直接对任意本地 Git checkout 调用公开 parser API:
在回归 fixture 中,修复后上传结果应只包含
notes/article.md;main.py、08_Attachments/diagram.md和notes/private.excalidraw.md均应被排除。验证
在
origin/mainrevision5bfa9b617ecff478f825ca435a35bc4222b30582上,新回归测试先失败:即使设置了fixture 仍上传 4 个文件。应用修复后只保留
notes/article.md。tests/test_upload_utils.py、tests/parse/test_directory_scan.py及 focused Git repository regression:82 passed;py_compilepassed;git diff --checkpassed。对主干的风险与未覆盖
风险较低且仅限 repository upload filtering。未显式传入过滤参数的调用保持原行为;自定义
ignore_dirs继续与内置忽略项叠加,与普通目录 parser 的契约一致。