From bc59a2162de5d47f96d28b87a45c27d15e975f2a Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 18 Dec 2025 20:51:26 +0000 Subject: [PATCH] feat: add dates to changelog version headers - Update generate-changelog.md to include dates in format (YYYY-MM-DD) - Add test to require dates for versions >= 0.1.19 - Add comment to create-release-tag.yml confirming date format support --- .claude/commands/generate-changelog.md | 2 +- .github/workflows/create-release-tag.yml | 2 ++ tests/test_changelog.py | 39 ++++++++++++++++++++++++ 3 files changed, 42 insertions(+), 1 deletion(-) diff --git a/.claude/commands/generate-changelog.md b/.claude/commands/generate-changelog.md index 3a67279..601595f 100644 --- a/.claude/commands/generate-changelog.md +++ b/.claude/commands/generate-changelog.md @@ -5,7 +5,7 @@ description: Generate changelog for a new release version You are updating the changelog for the new release. -Update CHANGELOG.md to add a new section for the new version at the top of the file, right after the '# Changelog' heading. +Update CHANGELOG.md to add a new section for the new version at the top of the file, right after the '# Changelog' heading. Use today's date in the version header in the format `## X.Y.Z (YYYY-MM-DD)` (e.g., `## 0.1.19 (2025-01-15)`). Review the recent commits and merged pull requests since the last release to generate meaningful changelog content for the new version. Follow the existing format in CHANGELOG.md with sections like: - Breaking Changes (if any) diff --git a/.github/workflows/create-release-tag.yml b/.github/workflows/create-release-tag.yml index c50abab..b0b9b8d 100644 --- a/.github/workflows/create-release-tag.yml +++ b/.github/workflows/create-release-tag.yml @@ -43,6 +43,8 @@ jobs: VERSION="${{ steps.extract_version.outputs.version }}" # Extract changelog section for this version to a temp file + # Works with both "## X.Y.Z" and "## X.Y.Z (YYYY-MM-DD)" formats + # since awk splits on whitespace ($2 is just the version number) awk -v ver="$VERSION" ' /^## / { if (found) exit diff --git a/tests/test_changelog.py b/tests/test_changelog.py index be0f219..6515f20 100644 --- a/tests/test_changelog.py +++ b/tests/test_changelog.py @@ -31,6 +31,45 @@ class TestChangelog: assert len(versions) > 0, "Changelog should contain at least one version" + def test_new_versions_have_dates(self): + """Versions >= 0.1.19 should have dates in the format (YYYY-MM-DD).""" + content = self.changelog_path.read_text() + lines = content.split("\n") + + # Version threshold for requiring dates (0.1.19 and above) + date_required_threshold = (0, 1, 19) + + version_with_date_pattern = re.compile( + r"^## (\d+)\.(\d+)\.(\d+)\s+\((\d{4})-(\d{2})-(\d{2})\)$" + ) + version_without_date_pattern = re.compile(r"^## (\d+)\.(\d+)\.(\d+)$") + + for line in lines: + if line.startswith("## "): + # Try to match version with date first + match_with_date = version_with_date_pattern.match(line) + if match_with_date: + # Validate date components + year, month, day = ( + int(match_with_date.group(4)), + int(match_with_date.group(5)), + int(match_with_date.group(6)), + ) + assert 2020 <= year <= 2100, f"Invalid year in date: {line}" + assert 1 <= month <= 12, f"Invalid month in date: {line}" + assert 1 <= day <= 31, f"Invalid day in date: {line}" + continue + + # Check if version without date + match_without_date = version_without_date_pattern.match(line) + if match_without_date: + version_tuple = tuple(int(x) for x in match_without_date.groups()) + if version_tuple >= date_required_threshold: + raise AssertionError( + f"Version {line} is >= 0.1.19 and must have a date " + f"in the format '## X.Y.Z (YYYY-MM-DD)'" + ) + def test_changelog_has_bullet_points(self): content = self.changelog_path.read_text() lines = content.split("\n")