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
+15
View File
@@ -239,6 +239,12 @@ func hashFile(f *os.File) (hash [32]byte, binary bool, ok bool) {
func protected(name string) bool {
for _, part := range strings.Split(strings.ToLower(name), "/") {
// A committed template (.env.example, config.key.sample) holds
// placeholders, not secrets; excluding it would mark every capture of
// such a repository incomplete.
if template(part) {
continue
}
if part == ".git" || part == "secrets" || part == ".ssh" || part == ".aws" || part == ".gnupg" || part == ".kube" || part == "node_modules" {
return true
}
@@ -249,6 +255,15 @@ func protected(name string) bool {
return false
}
func template(part string) bool {
for _, suffix := range []string{".example", ".sample", ".template", ".dist"} {
if strings.HasSuffix(part, suffix) {
return true
}
}
return false
}
type boundedOutput struct {
bytes.Buffer
limit int