diff options
| author | Bernhard Guillon <Bernhard.Guillon@begu.org> | 2026-07-06 21:47:30 +0200 |
|---|---|---|
| committer | Bernhard Guillon <Bernhard.Guillon@begu.org> | 2026-07-06 21:47:30 +0200 |
| commit | 5137f2cf25a71cfaf6d7794d86ea2ed52bb001d3 (patch) | |
| tree | 11f43bb2caef501f039500c627c9946042aa27ed | |
| parent | ad7575e85ebf6332d324ca5997db18ea81065df4 (diff) | |
| download | sourcewatch-5137f2cf25a71cfaf6d7794d86ea2ed52bb001d3.tar.gz sourcewatch-5137f2cf25a71cfaf6d7794d86ea2ed52bb001d3.zip | |
Docker test fixes: directory pattern matching, mtime-based sync, Go version
- Fixed directory pattern matching: go-gitignore doesn't match 'build/'
against bare 'build', now checks with trailing slash appended
- Added ModTime to FileMeta for reliable change detection (same-size
file modifications now sync correctly)
- Updated Dockerfile to golang:1.24-alpine (was 1.22)
- Downgraded go.mod to Go 1.24 (system has custom 1.26.4 build)
Docker tested with podman:
- Initial sync correctly excludes ignored dirs/files
- Nested .gitignore works (sub/ ignores *.tmp)
- Watcher syncs new/modified/deleted files
- Case-sensitive rename (Foo→foo) handled correctly
- Same-size file modifications sync correctly
| -rw-r--r-- | Dockerfile | 2 | ||||
| -rw-r--r-- | gitignore.go | 4 | ||||
| -rw-r--r-- | go.mod | 2 | ||||
| -rw-r--r-- | sync.go | 3 | ||||
| -rw-r--r-- | watcher.go | 8 |
5 files changed, 12 insertions, 7 deletions
@@ -1,4 +1,4 @@ -FROM golang:1.22-alpine AS builder +FROM golang:1.24-alpine AS builder WORKDIR /src COPY go.mod go.sum ./ RUN go mod download diff --git a/gitignore.go b/gitignore.go index 569e191..2c9fc4b 100644 --- a/gitignore.go +++ b/gitignore.go @@ -50,8 +50,8 @@ func (s *GitignoreStack) IsIgnored(relPath string) bool { continue } - posMatch := layer.posRules != nil && layer.posRules.MatchesPath(childRel) - negMatch := layer.negRules != nil && layer.negRules.MatchesPath(childRel) + posMatch := layer.posRules != nil && (layer.posRules.MatchesPath(childRel) || layer.posRules.MatchesPath(childRel+"/")) + negMatch := layer.negRules != nil && (layer.negRules.MatchesPath(childRel) || layer.negRules.MatchesPath(childRel+"/")) if negMatch { result = false @@ -1,6 +1,6 @@ module sourcewatch -go 1.26.4 +go 1.24 require ( github.com/fsnotify/fsnotify v1.10.1 @@ -5,11 +5,13 @@ import ( "log" "os" "path/filepath" + "time" ) type FileMeta struct { Size int64 Mode os.FileMode + ModTime time.Time Symlink string } @@ -65,6 +67,7 @@ func initialSync(hostDir, dataDir string, stack *GitignoreStack, dryRun bool) (* meta := FileMeta{ Size: info.Size(), Mode: info.Mode(), + ModTime: info.ModTime(), Symlink: linkTarget, } manifest.Files[relPath] = meta @@ -127,6 +127,7 @@ func syncCreate(srcPath, destPath, relPath string, manifest *Manifest, stack *Gi meta := FileMeta{ Size: info.Size(), Mode: info.Mode(), + ModTime: info.ModTime(), Symlink: linkTarget, } manifest.Files[relPath] = meta @@ -161,13 +162,14 @@ func syncWrite(srcPath, destPath, relPath string, manifest *Manifest, dryRun, ve } meta, exists := manifest.Files[relPath] - if exists && meta.Size == info.Size() && meta.Mode == info.Mode() { + if exists && meta.Size == info.Size() && meta.Mode == info.Mode() && meta.ModTime.Equal(info.ModTime()) { return } manifest.Files[relPath] = FileMeta{ - Size: info.Size(), - Mode: info.Mode(), + Size: info.Size(), + Mode: info.Mode(), + ModTime: info.ModTime(), } if dryRun { |
