Skip to content

Handle empty staged-file lists in generated hooks #109

Description

@jmcte

Problem statement

The generated pre-commit hook runs with Bash strict mode and dereferences an empty staged-file array. Metadata-only commits or hook invocations with no staged paths can therefore fail before the hook performs any useful validation.

Desired outcome

Generated hooks accept an empty staged-file list while preserving all existing environment-file protections.

Scope

  • Expand the staged-file array safely when it is empty.
  • Ignore the fallback empty entry.
  • Add a generated-repository smoke test that invokes the hook with no staged files.

Acceptance criteria

  • The generated pre-commit hook exits successfully on a feature branch with no staged files.
  • Existing staged-file validation remains unchanged for non-empty entries.
  • The full Bootstrap check suite passes.

Security implications

The change must not weaken the hook's rejection of committed environment files.

Documentation implications

None; this restores the documented hook behavior.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions