Capture committed .env templates instead of skipping them

Every run in this repository reported an incomplete file-change capture
because the tracked .env.example matched the secret-file rules and was
skipped. Committed templates (.example, .sample, .template, .dist) hold
placeholders, so they are captured like any file; real secret files and
protected directories stay excluded.
This commit is contained in:
2026-11-10 17:49:58 +00:00
parent 440995e31f
commit 1b698a1241
2 changed files with 34 additions and 0 deletions
+19
View File
@@ -281,3 +281,22 @@ func TestGitStatusListsUncomparableChanges(t *testing.T) {
t.Fatalf("status/diagnostic = %q/%q", changes.Status, changes.Diagnostic)
}
}
func TestProtectedKeepsSecretsButNotCommittedTemplates(t *testing.T) {
for name, want := range map[string]bool{
".env": true,
".env.local": true,
"app/prod.env": true,
"certs/server.key": true,
"secrets/token.example": true, // a protected directory stays protected
".env.example": false,
"app/.env.sample": false,
"config/server.key.dist": false,
"deploy/.env.template": false,
"docs/example.md": false,
} {
if got := protected(name); got != want {
t.Errorf("protected(%q) = %v, want %v", name, got, want)
}
}
}