fix: stop the scratch-name match from pruning user directories

Đang mở Phù hợp với người mới
#385 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
82/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
go
Lĩnh vực
tooling

Hướng nghiên cứu

Bắt đầu tại internal/indexdir/filter.go (besideStore, khoảng dòng 109–114), nơi có phép so khớp chỉ dựa trên tên bằng strings.HasPrefix, rồi kiểm tra scratchdir.LockName để thay bằng kiểm tra nội dung. Tiếp theo, theo dõi pruning trong internal/indexer/discover/discoverexclusion.go:162-172 để xem bản ghi loại trừ được tạo ở đâu. Tái hiện bằng các bước mkdir/symlink trong issue; hoàn thành khi thư mục người dùng được lập chỉ mục (hoặc được ghi nhận kèm lý do), trong khi các thư mục scratch thực sự có chứa .lock vẫn bị pruning, và có một bài kiểm thử trong internal/indexdir.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

area:indexer bug needs-triage
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
  1. Run mkdir -p repo/.codegraph repo/store-real repo/store-real.scratch-notes.
  2. Run ln -s ../store-real repo/.codegraph/store.
  3. Write package a to repo/store-real.scratch-notes/a.go, and package main to repo/main.go.
  4. 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
Ngôn ngữ chính
Go
Star
0
Fork
0
Merge trung bình
5 giờ 16 phút
Pull request đã merge (30 ngày)
107

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của seanb4t/codegraph-go

Tất cả issue của seanb4t/codegraph-go

Issue tương tự

Thêm issue về Go

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.