Commit e55f0bf
committed
feat(init): auto-update .gitignore so static.md is trackable
A common onboarding stumble: user follows the README, runs
`revive init`, then `git add .revive/static.md` — git silently
skips the file because their .gitignore has `.revive/*` (or
similar) and no exception. The "checked in" workflow the README
documents quietly fails.
`cmd_init` now calls `maybe_update_gitignore` after writing
static.md. Logic:
- Skip silently if not in a git repo, no .gitignore exists, or
`git check-ignore` says the file is already trackable.
- Otherwise append a small canonical block:
.revive/*
!.revive/static.md
with a header comment explaining what gets tracked vs not.
- Re-run `git check-ignore`. If a directory-level `.revive/`
rule still suppresses the un-ignore (git semantics: `!`
cannot rescue a file inside a fully-ignored directory), print
a warning telling the user how to fix it.
4 new tests cover: no .gitignore (no-op), `.revive/*` (append +
verify trackable), already-correct (idempotent — line count
unchanged), `.revive/` directory rule (warning emitted, exit 0
preserved).1 parent f27d72d commit e55f0bf
2 files changed
Lines changed: 72 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
697 | 697 | | |
698 | 698 | | |
699 | 699 | | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
700 | 733 | | |
701 | 734 | | |
702 | 735 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1430 | 1430 | | |
1431 | 1431 | | |
1432 | 1432 | | |
| 1433 | + | |
| 1434 | + | |
| 1435 | + | |
| 1436 | + | |
| 1437 | + | |
| 1438 | + | |
| 1439 | + | |
| 1440 | + | |
| 1441 | + | |
| 1442 | + | |
| 1443 | + | |
| 1444 | + | |
| 1445 | + | |
| 1446 | + | |
| 1447 | + | |
| 1448 | + | |
| 1449 | + | |
| 1450 | + | |
| 1451 | + | |
| 1452 | + | |
| 1453 | + | |
| 1454 | + | |
| 1455 | + | |
| 1456 | + | |
| 1457 | + | |
| 1458 | + | |
| 1459 | + | |
| 1460 | + | |
| 1461 | + | |
| 1462 | + | |
| 1463 | + | |
| 1464 | + | |
| 1465 | + | |
| 1466 | + | |
| 1467 | + | |
| 1468 | + | |
| 1469 | + | |
| 1470 | + | |
| 1471 | + | |
0 commit comments