Skip to content

Commit 469fbba

Browse files
committed
remove symlink
1 parent cad6790 commit 469fbba

File tree

2 files changed

+3
-41
lines changed

2 files changed

+3
-41
lines changed

pkg/ecosystems/discovery/README.md

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ Efficient file discovery utilities for finding manifest and configuration files
1111
- **Exclude Patterns**: Skip directories and files using glob patterns
1212
- **Context Support**: Cancellable operations for long-running searches
1313
- **Efficient Traversal**: Uses `filepath.WalkDir` for optimal performance
14-
- **Symlink Handling**: Optional symlink following
1514
- **Structured Logging**: `slog` integration for debugging
1615

1716
## Usage
@@ -96,14 +95,6 @@ results, err := discovery.FindFiles(ctx, "/path/to/project",
9695
discovery.WithExcludes("node_modules", ".*", "__pycache__"))
9796
```
9897

99-
### Follow Symlinks
100-
101-
```go
102-
results, err := discovery.FindFiles(ctx, "/path/to/project",
103-
discovery.WithInclude("*.txt"),
104-
discovery.WithFollowSymlinks(true))
105-
```
106-
10798
### Common Exclude Patterns
10899

109100
```go

pkg/ecosystems/discovery/files.go

Lines changed: 3 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,9 @@ const (
1919

2020
// findOptions configures file discovery behavior.
2121
type findOptions struct {
22-
targetFiles []string
23-
includeGlobs []string
24-
excludeGlobs []string
25-
followSymlinks bool
22+
targetFiles []string
23+
includeGlobs []string
24+
excludeGlobs []string
2625
}
2726

2827
// FindOption is a functional option for configuring file discovery.
@@ -70,13 +69,6 @@ func WithExcludes(patterns ...string) FindOption {
7069
}
7170
}
7271

73-
// WithFollowSymlinks enables or disables following symbolic links.
74-
func WithFollowSymlinks(follow bool) FindOption {
75-
return func(o *findOptions) {
76-
o.followSymlinks = follow
77-
}
78-
}
79-
8072
// FindResult represents a discovered file.
8173
type FindResult struct {
8274
Path string // Absolute path to the file
@@ -241,11 +233,6 @@ func walkDirectory(ctx context.Context, absRoot string, opts *findOptions) ([]Fi
241233
return handleDirectory(d, relPath, opts.excludeGlobs)
242234
}
243235

244-
// Handle symlinks
245-
if d.Type()&fs.ModeSymlink != 0 && !shouldFollowSymlink(path, relPath, opts.followSymlinks) {
246-
return nil
247-
}
248-
249236
// Check exclusions and pattern match for files
250237
if shouldIncludeFile(d, relPath, opts) {
251238
results = append(results, FindResult{
@@ -298,22 +285,6 @@ func handleDirectory(d fs.DirEntry, relPath string, excludePatterns []string) er
298285
return nil
299286
}
300287

301-
// shouldFollowSymlink determines if a symlink should be followed.
302-
func shouldFollowSymlink(path, relPath string, followSymlinks bool) bool {
303-
if !followSymlinks {
304-
slog.Debug("Skipping symlink", slog.String(logKeyPath, relPath))
305-
return false
306-
}
307-
308-
// Resolve symlink and check if it's a file
309-
targetInfo, err := os.Stat(path)
310-
if err != nil || targetInfo.IsDir() {
311-
return false
312-
}
313-
314-
return true
315-
}
316-
317288
// shouldIncludeFile determines if a file should be included in results.
318289
// Returns true if the file matches any of the include globs and is not excluded.
319290
func shouldIncludeFile(d fs.DirEntry, relPath string, opts *findOptions) bool {

0 commit comments

Comments
 (0)