Skip to content

Accept existing copyright years while using the current year for header fixes #231

Description

@jfdev001

I'd like to check and format copyright headers without deriving copyright years from Git history. Enabling Git history attributes is too slow for our repository, and we do not need to verify the historical accuracy of the year.

Desired behavior

  • If the header matches the configured format and contains a four-digit year (e.g., copyright header could accept patterns like 20[0-9]{2}), accept it unchanged, regardless of whether it matches the current year.
  • If the header is missing, insert the configured header using the current year. So something like attrs.current_year, independent of Git history.
  • If a recognizable header is malformed, such as having incorrect spacing, replace it with the configured header using the current year.
  • Preserve unrelated comments and report conflicting copyright headers rather than overwriting them.

For example, assuming the current year is 2026, this valid header should remain unchanged:

/*
 * Copyright 2023 Example Company.
 */

But this malformed header:

/*
 *Copyright 2023 Example Company.
 */

should become:

/*
 * Copyright 2026 Example Company.
 */

Configuration

I'd like to keep Git-ignore handling enabled while disabling Git history attributes:

[git]
ignore = "enable"
file_attrs = "disable"

Is this possible with the existing configuration? If not, would you consider an optional feature that separates accepted copyright years from the year used when generating or repairing headers?

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

    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