fix: stop the scratch-name match from pruning user directories
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
调研方向
从 internal/indexdir/filter.go(besideStore,大约第 109–114 行)开始,找到仅按名称进行的 strings.HasPrefix 匹配,并检查 scratchdir.LockName,以改用内容检查。然后跟进 internal/indexer/discover/discoverexclusion.go:162-172 中的 pruning,查看排除记录在哪里创建。按照 issue 中的 mkdir/symlink 步骤重现;完成的标准是用户目录被索引(或记录并附带原因),同时包含 .lock 的真实 scratch 目录仍会被 pruning,并且在 internal/indexdir 下有一个测试。
由索引模型根据 Issue 内容生成。
描述
What happens
The index skips any directory whose name starts with the store name followed by .scratch-. A user directory with such a name is skipped too. Discovery prunes it with no exclusion record, so its files are missing from the index and no reason is reported. This follows PR #384, which introduces the name match in internal/indexdir/filter.go.
Reproduced on commit 375d8be6 of branch fix/index-path-links, built from source:
$ codegraph index --force repo
files=1 nodes=2 edges=1 duration=82ms
Only repo/main.go is indexed. repo/store-real.scratch-notes/a.go is absent.
The cause is besideStore in internal/indexdir/filter.go:109-114. It matches a scratch directory by strings.HasPrefix on the name alone. DiscoverAll then prunes the matching directory before it makes any record (internal/indexer/discover/discoverexclusion.go:162-172).
What you expected instead
A directory that codegraph did not create is indexed as source, or it gets an exclusion record with a reason. Only a real scratch directory is pruned.
The match must check the content of the directory, such as its lock file .lock (scratchdir.LockName), and not the name alone. A scratch name ends in a random suffix, so the name cannot tell a scratch directory from a user directory.
Steps to reproduce
- Run
mkdir -p repo/.codegraph repo/store-real repo/store-real.scratch-notes. - Run
ln -s ../store-real repo/.codegraph/store. - Write
package atorepo/store-real.scratch-notes/a.go, andpackage maintorepo/main.go. - Run
codegraph index --force repo. Only one file is indexed.
Version
codegraph dev (commit unknown, built unknown) go1.26.11 darwin/arm64, built from 375d8be6.
Platform
macOS 27.2.1 arm64
How did you install it?
Built from source
Languages in the affected repository
Go. The bug depends on directory names, not on the language.
Before submitting
- I searched existing issues and this is not a duplicate
- I checked the capability matrix and this is not a documented limitation
- This is not a security vulnerability
- 主要语言
- Go
- 星标
- 0
- 派生
- 0
- 平均合并
- 5 小时 16 分钟
- 30 天内合并 PR
- 107
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
seanb4t/codegraph-go 的其他 Issue
-
chore needs-triage
难度 1/5 1 小时以内 新手友好度 88/100
seanb4t/codegraph-go#380 ·
维护者通常 1 天内回复
-
chore needs-triage
难度 2/5 1-3 小时 新手友好度 82/100
seanb4t/codegraph-go#379 ·
维护者通常 1 天内回复
-
chore needs-triage
难度 1/5 1-3 小时 新手友好度 84/100
seanb4t/codegraph-go#362 ·
维护者通常 1 天内回复
-
area:query bug priority:low spec-needed
难度 2/5 1-3 小时 新手友好度 80/100
seanb4t/codegraph-go#355 ·
维护者通常 1 天内回复
-
area:ci chore priority:low
难度 2/5 1-3 小时 新手友好度 72/100
seanb4t/codegraph-go#329 ·
维护者通常 1 天内回复
查看 seanb4t/codegraph-go 的全部 Issue
相似的 Issue
-
enhancement exporter/awskinesis needs triage
难度 2/5 1-3 小时 新手友好度 70/100
open-telemetry/opentelemetry-collector-contrib#53334 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
erigontech/erigon#26523 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 83/100
SocialGouv/iterion#3376 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 72/100
seaweedfs/seaweedfs#12740 · 2 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复