Skip to content

Add --keep-existing-license option to insert-license hook #108

Description

@noamfadida-97

Summary

Add an option to the insert-license hook so that files that already have a license header are left unchanged (no year update, no removal). Files without a license would still get one inserted.

Motivation

  • Some teams want to keep only the creation year in headers and not have the hook update existing years to a range (e.g. keep 2015 instead of changing to 2015-2025).
  • The combination --allow-past-years + --use-current-year still edits existing headers (updates to a year range). There was no way to say “never touch an existing license.”
  • With this option, existing signatures stay as-is; only files missing a license get a new header (and with --use-current-year, that new header uses the current year).

Proposed solution

Add a flag, e.g. --keep-existing-license:

  • If a file already has a matching license header → do nothing (no year update, no removal).
  • If a file has no license → insert the license as today (with --use-current-year, use current year in the inserted text).

When used with --use-current-year:

  • Files that already have a license (including past years) are left unchanged.
  • Files with no license get a new header with the current year.

Implementation

  • New CLI argument --keep-existing-license (store_true).
  • When a license is found in a file and this flag is set, skip that file (no call to update/remove).
  • Document in README and clarify the difference from --allow-past-years + --use-current-year.

References

  • Branch with implementation: feat/insert-license-keep-existing
  • Commits: feat(insert-license): add --keep-existing-license option; docs; tests.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions