fix: pull ~/.dotfile automatically from ordinary ff commands

Daily ff subcommands never updated the repo; only `ff update` did.
Add a pouch-style interval auto-update at the ff entry (default 24h),
skip dirty/fail/timeout without aborting the current command, and
cover the skip/pull cases with a fish regression.
This commit is contained in:
2026-10-13 16:25:05 +08:00
parent 2ede67d1c9
commit 59e2356f5c
4 changed files with 419 additions and 11 deletions
+4
View File
@@ -10,6 +10,8 @@ ff script <name> # 运行脚本
make -f Makefile.scripts <name> # 同上(make 入口)
ff region # 切换 CN_REGION(国内/国外镜像)
ff reload # 重载 fish 配置
ff update # 立即 git pull origin main 并 reload
fish fish/tests/ff-auto-update.fish # ff 自动更新回归
```
## 目录职责
@@ -59,6 +61,7 @@ ff reload # 重载 fish 配置
- 跑脚本:`ff script <name>` 或 `ff s <name>`(走 `execute-script.fish`)
- 列脚本:`ff script -h`
- 新增 `ff` 子命令时:改 `fish/functions/ff.fish` + `fish/completions/ff.fish`
- **自动更新**:日常 `ff` 命令超过间隔(默认开、24h)会顺带 `git pull --ff-only origin main` 更新 `~/.dotfile`,成功且有新提交后再 reload。配置在本机 `~/.config/ff/config`(`enabled`、`interval`),时间戳 `~/.local/share/ff/state`,不要进 git。跳过:`FF_NO_AUTO_UPDATE=1` 或 `ff --no-auto-update …`。显式 `ff update` 立即拉取并刷新时间戳,这次不再走自动更新。脏工作区、超时、网络失败时 stderr 一行并继续当前命令。回归:`fish fish/tests/ff-auto-update.fish`
## Git 配置
@@ -78,6 +81,7 @@ ff reload # 重载 fish 配置
- 不要把密钥、webhook、本机专用路径写进 git(`script/clash.sh` 等已在 `.gitignore`)
- 不要改 `~/.config/fish/config.fish` 进仓库;本机差异放 `custom.fish`
- 不要把本机 `mise use -g` 的工具写进 `mise/config.toml`;写 `~/.config/mise/config.toml`
- 不要把 `~/.config/ff/config` 或 `~/.local/share/ff/state` 写进 git(本机自动更新配置)
- 不要为 init 复制整份配置到 `$HOME`;**优先软链接**到 dotfile
- 脚本改动保持最小 diff,风格与相邻脚本一致(bash、`set -euo pipefail` 视情况)
- 未经明确要求不要 `git commit` / `git push`