Skip to content

Commit c11f6fc

Browse files
author
Itay Donanhirsh
committed
ignore symlinks
1 parent 770761f commit c11f6fc

4 files changed

Lines changed: 39 additions & 8 deletions

File tree

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,18 @@ These tags are written as a normal tag to the index, with an added attribute `se
109109
* somewhere:1.1-19 lang=hs search=glob
110110
```
111111

112+
### Pragma Tags
113+
114+
There are only two pragma tags implemented: `%stop` and `%cont`. Example:
115+
116+
```
117+
[# to_be #]
118+
[# %stop #]
119+
[# or_not_to_be #]
120+
[# %cont #]
121+
[# that_is_the_question #]
122+
```
123+
112124
## Index
113125

114126
To generate an index, use:
@@ -178,6 +190,12 @@ scanner:
178190
right: "#]"
179191
```
180192
193+
## Caveats
194+
195+
- Only textual files are scanned.
196+
- Tags are scanned whether they are in a comment or not.
197+
- Links are ignored.
198+
181199
## Integrations
182200
183201
- [Vim Plugin](https://github.com/cluttercode/vim-clutter)

cmd/clutter/index.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,11 @@ func readIndex(c *cli.Context) (*index.Index, error) {
5656
continue
5757
}
5858

59-
if path == "" {
60-
path = "stdin"
59+
if path != "" {
60+
path = path + ": "
6161
}
6262

63-
return nil, fmt.Errorf("%s: %w", path, err)
63+
return nil, fmt.Errorf("%s%w", path, err)
6464
}
6565

6666
z.Infow("index read", "n", idx.Size())

internal/pkg/scanner/filter.go

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,29 @@ func NewFilter(z *zap.SugaredLogger, cfg Config) (func(string, os.FileInfo) (boo
2727
exclude := gitignore.NewMatcher(ignores).Match
2828

2929
return func(path string, fi os.FileInfo) (bool, error) {
30-
isDir := fi != nil && fi.IsDir()
30+
var (
31+
isDir, isLink bool
32+
mode os.FileMode
33+
)
34+
35+
if fi != nil {
36+
mode = fi.Mode()
37+
isDir = fi.IsDir()
38+
isLink = mode&os.ModeSymlink != 0
39+
}
3140

3241
split := strings.Split(path, string(filepath.Separator))
3342

34-
z := z.With("path", split, "is_dir", isDir)
43+
z := z.With("path", split, "is_link", isLink, "is_dir", isDir, "mode", mode)
44+
45+
if isLink {
46+
z.Debug("links are excluded")
47+
48+
return false, nil
49+
}
3550

3651
if exclude(split, isDir) {
37-
z.Debug("exclude")
52+
z.Debug("exclude dir")
3853

3954
if isDir {
4055
return false, filepath.SkipDir

internal/pkg/scanner/scan.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,6 @@ func ScanReader(
4545
for i := 0; scanner.Scan(); i++ {
4646
line := scanner.Text()
4747

48-
z.Debugw("read", "line", line)
49-
5048
ms := re.FindAllStringIndex(line, -1)
5149

5250
for _, m := range ms {

0 commit comments

Comments
 (0)