Skip to content

fix: enforce current year in copyright header of new files#36

Closed
alexmohr wants to merge 2 commits into
mainfrom
feature/enforce-current-year-new-files
Closed

fix: enforce current year in copyright header of new files#36
alexmohr wants to merge 2 commits into
mainfrom
feature/enforce-current-year-new-files

Conversation

@alexmohr
Copy link
Copy Markdown
Contributor

@alexmohr alexmohr commented May 5, 2026

Summary

  • Fixes a gap in the reuse-annotate-hook.py where a newly added file that already carries an SPDX-FileCopyrightText header with a stale year was silently accepted
  • Adds is_git_new_file() to detect files not yet present in HEAD (via git ls-files + git show HEAD:<path>)
  • Adds check_copyright_year_for_new_file() to validate the year in the header matches the current year, failing with a clear error if not
  • Existing files are unaffected — only new files with a pre-written wrong year are rejected
  • Not configurable by design; the current year is the only correct value for a brand-new file

Checklist

  • I have tested my changes locally
  • I have added or updated documentation
  • I have linked related issues or discussions
  • I have added or updated tests

Related

Notes for Reviewers


Alexander Mohr alexander.m.mohr@mercedes-benz.com, Mercedes-Benz Tech Innovation GmbH
Provider Information

@alexmohr alexmohr force-pushed the feature/enforce-current-year-new-files branch from 5c1a92b to 0544fba Compare May 5, 2026 19:51
alexmohr added 2 commits May 6, 2026 04:49
When a new file (not yet present in HEAD) already carries an
SPDX-FileCopyrightText header, validate that the year matches the
current year. Existing files are unchanged - only the annotation
path (no prior header) is affected, which already stamps the current
year via reuse annotate. The new check covers the gap where a
developer manually writes a stale year in a brand-new file.

Signed-off-by: Alexander Mohr <alexander.m.mohr@mercedes-benz.com>
@alexmohr alexmohr force-pushed the feature/enforce-current-year-new-files branch from 0544fba to 9d12c1e Compare May 6, 2026 04:52
@alexmohr
Copy link
Copy Markdown
Contributor Author

alexmohr commented May 6, 2026

Work integrated into PR #39 (feat/pre-commit-hook-args-config). The enforce-current-year logic was rebased onto the args-config branch and the os.environ fallbacks replaced with clean argparse defaults.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant