Skip to content

Keep an existing COPYRIGHT.md instead of rewriting it from the clock [patch] - #233

Merged
matt-edmondson merged 1 commit into
mainfrom
fix/222-keep-existing-copyright
Oct 9, 2026
Merged

matt-edmondson merged 1 commit into
mainfrom
fix/222-keep-existing-copyright

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Fixes #222

What changed

LicenseGenerator rebuilt Copyright (c) 2023-{DateTime.UtcNow.Year} … on every run. The first ci run of 2027 would commit 2023-2027, and since ktsu.Sdk derives file_header_template from COPYRIGHT.md, every repository would fail IDE0073 on every source file.

  • An existing, non-empty COPYRIGHT.md is now kept verbatim, and LICENSE.md carries the same line, so the two can't drift.
  • A missing or blank COPYRIGHT.md is still generated, in the same 2023-{year} format as before.
  • The public GenerateAsync signature is unchanged. It forwards to a new internal overload that takes currentYear, so tests can freeze the clock. Both callers (MetadataService and the license CLI command) pick up the new behaviour without changes.

Not in scope (worth a separate decision):

  • Seeding a new repository with its real start year rather than 2023, which the issue calls out as a separate problem.
  • Detecting an owner rename in an existing COPYRIGHT.md. The kept text wins, which matches "advance it deliberately, not as a side effect of ci".

Tests

New LicenseGeneratorTests:

  • GenerateAsync_NewYear_KeepsExistingCopyright: an existing 2023-2026 file, run with the clock frozen at 2027, stays byte-identical, and LICENSE.md carries it with no 2027. It fails when the old clock-derived line is restored and passes with the fix.
  • GenerateAsync_NoCopyrightFile_GeneratesOneForTheCurrentYear and GenerateAsync_EmptyCopyrightFile_IsRegenerated check that generation still works when there's nothing to keep.

The existing GenerateAsync_IncludesYearRange still passes, since it runs with no existing file. The full suite passes (786/786), and KtsuBuild.csproj builds across all its target frameworks.

Each consuming repository needs to pick up the new KtsuBuild release before 2027-01-01.

🤖 Generated with Claude Code

https://claude.ai/code/session_01T4yQx7YuowTGorXJRkhe8x


Generated by Claude Code

…[patch]

LicenseGenerator rebuilt the copyright line from DateTime.UtcNow on every
run, so the first ci run of 2027 would write "2023-2027" into COPYRIGHT.md
and commit it. ktsu.Sdk derives every source file's required header from
COPYRIGHT.md, so every repository would then fail IDE0073 on every file.

An existing, non-empty COPYRIGHT.md is now kept as it is, and LICENSE.md
carries its text. A repository without one still gets one generated. The
year comes in through an internal overload so tests can freeze it.

Fixes #222

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01T4yQx7YuowTGorXJRkhe8x
@sonarqubecloud

sonarqubecloud Bot commented Oct 8, 2026

Copy link
Copy Markdown

@matt-edmondson
matt-edmondson merged commit fa4a559 into main Oct 9, 2026
14 checks passed
@matt-edmondson
matt-edmondson deleted the fix/222-keep-existing-copyright branch October 9, 2026 08:02
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.

On 1 January 2027, ci will rewrite COPYRIGHT.md to "2023-2027" and every ktsu-dev repo's build will fail IDE0073 on every source file

1 participant