Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
2183d06
Implement the Linux daemon: inotify watcher, engine, CLI
Will-Howard Jul 28, 2026
6689afd
Add the Linux install path
Will-Howard Jul 28, 2026
5faedb3
Consolidate the Linux implementation into three files
Will-Howard Jul 28, 2026
7b924da
Trim and tighten comments in the consolidated CLI and git driver
Will-Howard Jul 29, 2026
b2b26d5
Apply review feedback to the Linux CLI and git driver
Will-Howard Jul 29, 2026
f4807a0
Move the parity tests into gitwatch_parity_test.go
Will-Howard Jul 29, 2026
9a73ea3
Move the gitwatch reference script to a top-level oracle/
Will-Howard Jul 29, 2026
1eb3ffd
Trim comments in the daemon
Will-Howard Jul 29, 2026
937a059
Make the Linux daemon file read top to bottom
Will-Howard Jul 29, 2026
93bd845
Escalate gitwatchd stop to SIGKILL
Will-Howard Jul 29, 2026
5f6c9e8
Turn autostart on for an installed daemon's first run
Will-Howard Jul 29, 2026
72d4206
Trim the oracle README
Will-Howard Jul 29, 2026
62e74ca
Update the install next steps for default-on autostart
Will-Howard Jul 29, 2026
2802880
Ignore the in-place Go binary in linux/
Will-Howard Jul 29, 2026
b401df0
Keep all persistent state in one flat state.json
Will-Howard Jul 29, 2026
626f1fd
Fold install.sh into the Makefile and harden uninstall
Will-Howard Jul 29, 2026
ba0ced9
Cut comment bloat from the autostart, state and install changes
Will-Howard Jul 29, 2026
edc64c3
Keep the push backoff at its cap instead of overflowing
Will-Howard Jul 29, 2026
d38875f
Raise the push retry cap to 30 minutes
Will-Howard Jul 29, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ NOTES.md

# Code-signing material (private key + CSR); never part of this repo
signing/

# Go binary built in-place by `go build .` in linux/ (make builds into build/)
/linux/gitwatchd
74 changes: 68 additions & 6 deletions linux/Makefile
Original file line number Diff line number Diff line change
@@ -1,20 +1,82 @@
# gitwatchd for Linux: a single static Go binary.
# make build build/gitwatchd for the host platform
# make test go vet + go test
# make clean remove build artifacts
# make build build/gitwatchd for the host platform
# make test go vet + go test
# make install put the binary on PATH and start the daemon (no sudo)
# make uninstall remove the binary, systemd unit and daemon state
# make clean remove build artifacts

GOFLAGS := -trimpath -ldflags "-s -w"
BUILD := build

.PHONY: all build test clean
# Install destination; empty means the first writable of /usr/local/bin,
# ~/.local/bin, ~/bin. Override as `make install DEST=/custom/bin`.
DEST ?=

.PHONY: all build test install uninstall clean

all: build

build:
CGO_ENABLED=0 go build $(GOFLAGS) -o build/gitwatchd .
CGO_ENABLED=0 go build $(GOFLAGS) -o $(BUILD)/gitwatchd .

test:
go vet ./...
go test ./...

# --- local install / uninstall ---
# Sudo-free: binary onto PATH, then started from there, which is what turns
# autostart on for the first run of an installed copy.

install: build
@$(BUILD)/gitwatchd stop >/dev/null 2>&1 || true
@DEST="$(DEST)"; \
if [ -n "$$DEST" ]; then mkdir -p "$$DEST"; else \
for d in /usr/local/bin "$$HOME/.local/bin" "$$HOME/bin"; do \
mkdir -p "$$d" 2>/dev/null || true; \
if [ -w "$$d" ]; then DEST="$$d"; break; fi; \
done; \
fi; \
if [ -z "$$DEST" ]; then \
echo " ⚠ no writable bin dir found. Install by hand: install -m 0755 $(BUILD)/gitwatchd /usr/local/bin/gitwatchd"; \
exit 1; \
fi; \
install -m 0755 $(BUILD)/gitwatchd "$$DEST/gitwatchd"; \
echo "✓ binary → $$DEST/gitwatchd"; \
case ":$$PATH:" in *":$$DEST:"*) ;; \
*) echo " ⚠ $$DEST is not on your PATH. Add: export PATH=\"$$DEST:\$$PATH\"";; esac; \
"$$DEST/gitwatchd" start
@echo " Next: gitwatchd . to watch the current repo"

# Uninstall never trusts PATH: everything is found by absolute path.
uninstall:
@for d in /usr/local/bin "$$HOME/.local/bin" "$$HOME/bin"; do \
[ -x "$$d/gitwatchd" ] && "$$d/gitwatchd" autostart off >/dev/null 2>&1 || true; \
done
@UNIT="$$HOME/.config/systemd/user/gitwatchd.service"; \
STATE="$${XDG_STATE_HOME:-$$HOME/.local/state}/gitwatchd"; GONE=""; \
if command -v systemctl >/dev/null 2>&1; then \
systemctl --user disable --now gitwatchd >/dev/null 2>&1 || true; \
fi; \
if [ -f "$$UNIT" ]; then \
rm -f "$$UNIT"; GONE="systemd unit"; echo " removed $$UNIT"; \
command -v systemctl >/dev/null 2>&1 && systemctl --user daemon-reload >/dev/null 2>&1 || true; \
fi; \
PID=$$(cat "$$STATE/gitwatchd.pid" 2>/dev/null); \
if [ -n "$$PID" ] && [ "$$(cat /proc/$$PID/comm 2>/dev/null)" = gitwatchd ]; then \
kill "$$PID" 2>/dev/null || true; \
for i in 1 2 3 4 5 6 7 8 9 10; do [ -d /proc/$$PID ] || break; sleep 0.2; done; \
[ -d /proc/$$PID ] && kill -9 "$$PID" 2>/dev/null; \
echo " stopped daemon (pid $$PID)"; \
fi; \
BIN=""; \
for d in /usr/local/bin "$$HOME/.local/bin" "$$HOME/bin"; do \
[ -f "$$d/gitwatchd" ] && rm -f "$$d/gitwatchd" && BIN=1 && echo " removed $$d/gitwatchd"; \
done; \
[ -n "$$BIN" ] && GONE="$${GONE:+$$GONE, }binary"; \
[ -d "$$STATE" ] && rm -rf "$$STATE" && GONE="$${GONE:+$$GONE, }daemon state"; \
if [ -n "$$GONE" ]; then echo "✓ uninstalled: $$GONE"; \
else echo "✓ nothing to uninstall: no gitwatchd binary, unit or state found"; fi
@echo " (config at ~/.gitwatchd kept: 'rm ~/.gitwatchd' to reset watched repos too)"

clean:
rm -rf build
rm -rf $(BUILD)
Loading
Loading