feat(auto-pull): opt-in background fast-forward for registered repos #60
Reference in New Issue
Block a user
Delete Branch "feat-auto-pull-registry"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Adds an opt-in system that background fast-forwards git repos when you
cdinto them — so your local clones (starting with the fish-config repo itself) stay current without manually remembering to pull. Motivated by repeatedly forgetting to pull the docs-regen CI commit onmain.Safety is the whole design: it only ever fast-forwards a clean repo whose branch has an upstream, and never in repos you haven't explicitly registered. It cannot rebase, merge, or overwrite committed or uncommitted work — worst case it's a no-op.
How it works
conf.d/auto-pull.fish(C2-guarded) — a--on-variable PWDhandler. On directory change it matches$PWDagainst the fish-config repo (always-covered baseline) + the user registry, via pure string prefix matching (nogitcall for unrelated dirs). A throttle fires it once per repo entry, not on every sub-directorycd, and clears on leaving so re-entry re-syncs. The sync runs backgrounded (&; disown) — zero prompt lag.functions/_auto_pull_sync.fish— the worker. Proceeds only when: clean work tree and branch has@{u}andgit merge --ff-onlyis possible. Any failed guard → no-op. Works on any branch (ff-only makes it safe).functions/auto-pull.fish— registry management:add/remove/list/status/-h. Usable even when C2 is disabled (it just edits a file);statusreports the C2 state.completions/auto-pull.fish— subcommand + registered-repo-basename completions.Registry
Machine-local plain text at
~/.config/.user-dots/fish/auto-pull.list(one absolute git-toplevel path per line) — never committed. The shipped config stays generic; your personal repo list lives in your git-ignored user-dots.addcreates the file if missing.Opinionated guard (C2)
Classified C2 (auto-execution). When
__fish_config_op_autoexecis off, the PWD handler is never registered → no auto-pull anywhere (including fish-config). Theauto-pullmanagement command still works.Scope note
Fires on repo entry, so it won't catch a commit that lands on the remote while you're already sitting in the repo (the exact CI-commit case that motivated this). Catching that needs a
fish_promptthrottle — deferred as a future enhancement, noted in AGENTS task #12.Tests performed (inline)
auto-pull add(cwd + path), dup detection, non-repo rejection, baseline rejection;removeby basename + missing-target error;list/statusoutput; bad-subcommand error.cd(entry fires, subdirs throttle, leaving clears, re-entry re-fires).fish -n.Manual Verification
auto-pull addinside a repo with a remote registers it;auto-pull listshows it alongside the fish-config baseline.cdout and back into that repo triggers a background fast-forward when it's cleanly behind its upstream (verify withgit log).git fetch.auto-pull remove <name>stops it from auto-pulling.set -U __fish_config_op_autoexec offdisables auto-pull (new shell);auto-pull statusreports DISABLED butadd/remove/liststill work.auto-pull -hshows colored help on stdout.auto-pull <tab>lists subcommands;auto-pull remove <tab>lists registered basenames.