feat(formula): add untracked status for formulas without .installed.json

When upgrading gt on an existing installation without .installed.json,
formulas that exist but don't match embedded were incorrectly marked as
"modified" (implying user customization). Now they're marked "untracked"
and are safe to update since there's no record of user modification.

This improves the upgrade experience:
- "modified" = tracked file user changed (skip update)
- "untracked" = file exists but not tracked (safe to update)

Adds 3 new tests for untracked scenarios.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
julianknutsen
2026-01-07 23:45:22 -08:00
committed by Steve Yegge
parent da2d71c3fe
commit 677a6ed84f
3 changed files with 242 additions and 13 deletions

View File

@@ -38,7 +38,7 @@ func (c *FormulaCheck) Run(ctx *CheckContext) *CheckResult {
}
// All good
if report.Outdated == 0 && report.Missing == 0 && report.Modified == 0 && report.New == 0 {
if report.Outdated == 0 && report.Missing == 0 && report.Modified == 0 && report.New == 0 && report.Untracked == 0 {
return &CheckResult{
Name: c.Name(),
Status: StatusOK,
@@ -63,6 +63,9 @@ func (c *FormulaCheck) Run(ctx *CheckContext) *CheckResult {
case "new":
details = append(details, fmt.Sprintf(" %s: new formula available", f.Name))
needsFix = true
case "untracked":
details = append(details, fmt.Sprintf(" %s: untracked (will update)", f.Name))
needsFix = true
}
}
@@ -83,6 +86,9 @@ func (c *FormulaCheck) Run(ctx *CheckContext) *CheckResult {
if report.New > 0 {
parts = append(parts, fmt.Sprintf("%d new", report.New))
}
if report.Untracked > 0 {
parts = append(parts, fmt.Sprintf("%d untracked", report.Untracked))
}
if report.Modified > 0 {
parts = append(parts, fmt.Sprintf("%d modified", report.Modified))
}