Summary
There is currently no automated enforcement of the ASF SPDX license header on source files.
Add the pre-commit framework with the
insert-license hook so that every commit
automatically checks (and optionally inserts) the required header.
Motivation
- Apache Airflow uses this exact setup to enforce license headers across
.py, .sh,
.yaml, .xml, .md and more via per-type templates in
scripts/ci/license-templates/
- Catches missing headers at commit time rather than at release time (when Apache RAT runs)
- ASF policy requires every source file to carry the SPDX Apache-2.0 header
Proposed changes
- Add
.pre-commit-config.yaml with Lucas-C/pre-commit-hooks insert-license hook
- Add license header templates under
scripts/ci/license-templates/ (one per file type)
- Configure hooks for
.py, .sh, .yaml/.yml, .toml, .cfg, .md
- Add
pre-commit to dev dependencies (or document pip install pre-commit && pre-commit install)
- Add a
make pre-commit target and run in CI
References
Summary
There is currently no automated enforcement of the ASF SPDX license header on source files.
Add the pre-commit framework with the
insert-licensehook so that every commitautomatically checks (and optionally inserts) the required header.
Motivation
.py,.sh,.yaml,.xml,.mdand more via per-type templates inscripts/ci/license-templates/Proposed changes
.pre-commit-config.yamlwithLucas-C/pre-commit-hooksinsert-licensehookscripts/ci/license-templates/(one per file type).py,.sh,.yaml/.yml,.toml,.cfg,.mdpre-committo dev dependencies (or documentpip install pre-commit && pre-commit install)make pre-committarget and run in CIReferences