diff options
| author | Bernhard Guillon <Bernhard.Guillon@begu.org> | 2026-07-06 21:21:53 +0200 |
|---|---|---|
| committer | Bernhard Guillon <Bernhard.Guillon@begu.org> | 2026-07-06 21:21:53 +0200 |
| commit | 7512c95fa3f4b4e4ccdf452024f314a9a3c3b60f (patch) | |
| tree | c38cfa736d70a2e2c5d1aae044f2c13ef96ae9fa /gitignore.go | |
| parent | b505ac2fe010fcc24b774c313d33dc099214e8ed (diff) | |
| download | sourcewatch-7512c95fa3f4b4e4ccdf452024f314a9a3c3b60f.tar.gz sourcewatch-7512c95fa3f4b4e4ccdf452024f314a9a3c3b60f.zip | |
Add sync and gitignore tests, fix loadGitignore bug
- Added gitignore_test.go: comprehensive tests for go-gitignore patterns
- Verified: *, **, [], negation, anchored patterns, comments
- Documented limitation: ? wildcard not supported by go-gitignore
- Added sync_test.go: integration tests for initial sync
- Tests: basic files, gitignore excludes, negation, double-star,
directory patterns, symlinks, permissions, dry-run, .git skip,
nested gitignore, complex combined patterns
- Fixed gitignore.go: use CompileIgnoreFile instead of passing
entire file content as single string to CompileIgnoreLines
Diffstat (limited to 'gitignore.go')
| -rw-r--r-- | gitignore.go | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/gitignore.go b/gitignore.go index f6816bd..80d14a6 100644 --- a/gitignore.go +++ b/gitignore.go @@ -10,13 +10,9 @@ import ( func loadGitignore(hostDir string) (*ignore.GitIgnore, error) { gitignorePath := filepath.Join(hostDir, ".gitignore") - data, err := os.ReadFile(gitignorePath) - if err != nil { - if os.IsNotExist(err) { - return ignore.CompileIgnoreLines(), nil - } - return nil, err + if _, err := os.Stat(gitignorePath); os.IsNotExist(err) { + return ignore.CompileIgnoreLines(), nil } - return ignore.CompileIgnoreLines(string(data)), nil + return ignore.CompileIgnoreFile(gitignorePath) } |
