aboutsummaryrefslogtreecommitdiffstats
path: root/README.md
blob: 46faabcffdc50fa09dcd097cd7de8a1d4a59c641 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# sourcewatch

A file synchronization tool that watches a source directory and syncs changes to a destination, respecting `.gitignore` rules. Designed to run in Docker/Podman on Windows with a read-only bind mount.

## How it works

1. **Initial sync** — copies all non-ignored files from `/host` to `/data`
2. **Watch** — monitors `/host` for changes and syncs them in real-time

## Building

```bash
# Build with Go (requires Go 1.24+)
go build -o sourcewatch .

# Build Docker/Podman image
docker build -t sourcewatch .
```

## Usage

```bash
# Linux
docker run -v /path/to/source:/host:ro -v watchdata:/data sourcewatch

# Windows
docker run -v c:\source:/host:ro -v watchdata:/data sourcewatch

# Podman (same syntax)
podman run -v c:\source:/host:ro -v watchdata:/data sourcewatch
```

## Flags

```
-host string      Host source directory (default "/host")
-data string      Data destination directory (default "/data")
-verbose          Enable verbose logging (shorthand for -log-level debug)
-log-level string Log level: debug, info, warn, error, none (default "info")
-dry-run          Preview what would be synced without copying
```

## Example

```bash
# Build
docker build -t sourcewatch .

# Run with verbose output
docker run -d --name watch \
  -v c:\myproject:/host:ro \
  -v project-data:/data \
  sourcewatch -verbose

# Check logs
docker logs -f watch

# Stop
docker rm -f watch
```

## .gitignore support

- Full gitignore spec: `*`, `**`, `[]`, `!` negation
- Nested `.gitignore` files (child patterns override parents)
- Patterns scoped to their directory
- `.git` directory always skipped

Example `.gitignore`:
```
*.log
build/
!important.log
```

## Limitations

- One-way sync only (`/host``/data`)
- `/host` must be read-only
- `?` single-character wildcard not supported (go-gitignore limitation)

## License

MIT