|
| 1 | +# CLAUDE.md — git-rain |
| 2 | + |
| 3 | +## Project Overview |
| 4 | + |
| 5 | +`git-rain` is a standalone Go CLI that syncs local git repositories _from_ their remotes — the reverse of `git-fire`. It is extracted from the `git-fire` codebase and promoted to a first-class tool. |
| 6 | + |
| 7 | +Module: `github.com/git-rain/git-rain` |
| 8 | +Go version: 1.24.2 |
| 9 | +Config: `~/.config/git-rain/config.toml` |
| 10 | +Registry: `~/.config/git-rain/repos.toml` |
| 11 | +Logs: `~/.cache/git-rain/` (not yet wired up) |
| 12 | + |
| 13 | +--- |
| 14 | + |
| 15 | +## Commands |
| 16 | + |
| 17 | +```bash |
| 18 | +make build # compile binary to ./git-rain |
| 19 | +make run ARGS="--dry-run" # build and run with flags |
| 20 | +make test # run all tests |
| 21 | +make test-race # run tests with race detector (used in CI) |
| 22 | +make lint # go vet ./... |
| 23 | +make install # install to $GOPATH/bin |
| 24 | +make clean # remove binary |
| 25 | +``` |
| 26 | + |
| 27 | +Run directly: |
| 28 | + |
| 29 | +```bash |
| 30 | +go build ./... |
| 31 | +go test -race -count=1 ./... |
| 32 | +go vet ./... |
| 33 | +``` |
| 34 | + |
| 35 | +--- |
| 36 | + |
| 37 | +## Architecture |
| 38 | + |
| 39 | +``` |
| 40 | +main.go |
| 41 | + └── cmd/root.go # Cobra CLI: flags, orchestration (rain is the root command) |
| 42 | + ├── internal/config # Load config (~/.config/git-rain/config.toml) |
| 43 | + ├── internal/git # Repo scanning + git operations (shells out to git binary) |
| 44 | + ├── internal/registry # Persistent repo registry (~/.config/git-rain/repos.toml) |
| 45 | + ├── internal/safety # Secret detection + error/log sanitization |
| 46 | + └── internal/flavor # Rain-themed startup quotes |
| 47 | +``` |
| 48 | + |
| 49 | +**Key design decisions:** |
| 50 | +- Uses native `git` binary via `exec.Command` — not go-git. |
| 51 | +- Backup branch prefix: `git-rain-backup-` (was `git-fire-rain-backup-` in git-fire). |
| 52 | +- Config env prefix: `GIT_RAIN_`. |
| 53 | +- Safe mode (default): never rewrites local-only commits. |
| 54 | +- Risky mode (`--risky` / `config: global.risky_mode`): allows hard reset to upstream after creating a `git-rain-backup-*` ref. |
| 55 | + |
| 56 | +--- |
| 57 | + |
| 58 | +## Testing |
| 59 | + |
| 60 | +- Run `make test-race` before considering a change done. |
| 61 | +- Prefer table-driven tests for multi-case functions. |
| 62 | +- Integration-style tests that shell out to `git` are preferred for `internal/git`. |
| 63 | +- Use `github.com/git-fire/git-testkit` helpers. |
| 64 | + |
| 65 | +--- |
| 66 | + |
| 67 | +## Conventions |
| 68 | + |
| 69 | +- **No go-git**: all git interactions shell out to the system `git` binary. |
| 70 | +- **Cobra for CLI**: root command lives in `cmd/root.go`. |
| 71 | +- **Config via Viper/TOML**: user config at `~/.config/git-rain/config.toml`; env vars override. |
| 72 | +- **Error handling**: return errors up to the caller; only `log.Fatal`/`os.Exit` in `main.go`. |
0 commit comments