fix(fs): 文件树 ignore 规则限定在工作空间自身的 git 仓库内 - #821
Draft
AlphaCatMeow wants to merge 1 commit into
Draft
AlphaCatMeow wants to merge 1 commit into
AlphaCatMeow wants to merge 1 commit into
Conversation
The file views walker (fs_list/fs_glob/fs_grep/fs_mention_list) applied gitignore rules even when the workspace is not a git repository (require_git(false)) and also honored ignore files in ancestor directories outside the workspace root (WalkBuilder's default parents(true)). Entries matching such rules silently vanished from the file tree - e.g. digit-leading folders matched by a stray [0-9]* rule, or folders created in Explorer that matched an ancestor's gitignore. - parents(false): the workspace root is the semantic boundary; outside ignore rules no longer leak in. - require_git(true): gitignore/global/exclude filtering only applies inside an actual git repository. - Existing gitignore-dependent test fixtures now initialize a fake .git directory; two regression tests cover the non-repo and ancestor-leak cases. Fixes Stack-Cairn#820
AlphaCatMeow
marked this pull request as draft
September 20, 2026 08:13
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.
问题
文件树(及 fs_glob/fs_grep/fs_mention_list)的目录遍历在"显示隐藏文件"关闭时误吞条目,用户可见症状为数字开头文件夹不显示、资源管理器新建的文件夹在文件树看不到(#820)。根因有两处:
require_git(false):非 git 目录里的.gitignore(以及全局 excludesFile)也生效;.parents(false):WalkBuilder默认向上读取祖先目录的 ignore 文件,工作空间外部的规则泄漏进来。两处均已用同版本
ignorecrate (=0.4.27) 独立复现确认。修复
build_workspace_walker(所有 fs 遍历命令的唯一入口):parents(false):工作空间根是文件视图的语义边界,外部 ignore 规则不再套用;require_git(true):gitignore 族过滤只在真实 git 仓库内生效。行为变化说明:workspace 是 monorepo 子目录时,仓库根的
.gitignore不再作用于文件树——对文件视图而言"少隐藏"比"条目凭空消失"更安全,且与用户在"显示隐藏文件"开关下的心智一致。测试
init_fake_git_repo(空.git目录即可满足require_git(true));mention_list_respects_gitignore_without_git_repository更名为..._inside_git_repository(语义随修复反转);list_ignores_gitignore_outside_git_repository:非仓库 +[0-9]*规则,数字目录必须出现;list_ignores_ancestor_gitignore_outside_workspace_root:父目录的仓库规则不得过滤子工作空间。验证:
cargo test -p liveagent --lib fs::tests43/43 通过。全量--lib的 23 个失败(git worktree / sandbox / hook 模块)经 stash 对照确认是本机环境存量问题,与本改动无关。用户侧临时绕过(未升级前)
git check-ignore -v --no-index <名字>可定位具体命中的规则与文件。Fixes #820