diff options
| author | Bernhard Guillon <Bernhard.Guillon@begu.org> | 2026-07-06 21:15:17 +0200 |
|---|---|---|
| committer | Bernhard Guillon <Bernhard.Guillon@begu.org> | 2026-07-06 21:15:17 +0200 |
| commit | b505ac2fe010fcc24b774c313d33dc099214e8ed (patch) | |
| tree | ff3f6472c84abd45e7918722e70ee681b859b780 /gitignore.go | |
| download | sourcewatch-b505ac2fe010fcc24b774c313d33dc099214e8ed.tar.gz sourcewatch-b505ac2fe010fcc24b774c313d33dc099214e8ed.zip | |
Initial project scaffolding
- main.go: CLI entry point with flag parsing
- gitignore.go: .gitignore loading and parsing
- sync.go: initial sync with manifest tracking
- watcher.go: fsnotify-based file watcher with debouncing
- Dockerfile: multi-stage build for Alpine runtime
Diffstat (limited to 'gitignore.go')
| -rw-r--r-- | gitignore.go | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/gitignore.go b/gitignore.go new file mode 100644 index 0000000..f6816bd --- /dev/null +++ b/gitignore.go @@ -0,0 +1,22 @@ +package main + +import ( + "os" + "path/filepath" + + ignore "github.com/sabhiram/go-gitignore" +) + +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 + } + + return ignore.CompileIgnoreLines(string(data)), nil +} |
