Bug description
cr_checker does not consistently handle copyright headers that are present but do not match the configured template.
When a file contains a copyright header with different wording, for example Apache License 2.0 or Apache License, Version 2.0 instead of the configured Apache License Version 2.0, the checker detects that the exact template does not match. It then detects that some copyright header is present, prints a warning, and leaves the file unchanged. The result is still reported as successful.
This is especially confusing when using the pre-commit hook, whose entry point is cr_checker/tool/cr_checker.py --fix: the hook name says “Check and fix”, but existing malformed headers are not fixed.
Expected behavior
A malformed existing header should either:
- be replaced with the configured canonical template when
--fix is used, or
- cause a non-zero exit status with a clear error when it is not fixed.
The behavior should also be documented if normalization is intentionally not supported.
Reproduction
- Configure the standard copyright template.
- Put a header containing
Apache License 2.0 in a BUILD file.
- Run cr_checker with
--fix.
- Observe that the header is unchanged and the command succeeds.
The behavior was observed through the copyright pre-commit hook in eclipse-score/docs-as-code#784. The pinned hook configuration is here.
Bug description
cr_checker does not consistently handle copyright headers that are present but do not match the configured template.
When a file contains a copyright header with different wording, for example
Apache License 2.0orApache License, Version 2.0instead of the configuredApache License Version 2.0, the checker detects that the exact template does not match. It then detects that some copyright header is present, prints a warning, and leaves the file unchanged. The result is still reported as successful.This is especially confusing when using the pre-commit hook, whose entry point is
cr_checker/tool/cr_checker.py --fix: the hook name says “Check and fix”, but existing malformed headers are not fixed.Expected behavior
A malformed existing header should either:
--fixis used, orThe behavior should also be documented if normalization is intentionally not supported.
Reproduction
Apache License 2.0in a BUILD file.--fix.The behavior was observed through the copyright pre-commit hook in eclipse-score/docs-as-code#784. The pinned hook configuration is here.