Skip to content

Commit 42bc180

Browse files
jwaldripclaude
andcommitted
fix: scope changelog generation to only include commits since previous version
The script was using HEAD~50..HEAD which grabbed all recent commits regardless of version boundaries, causing every entry to repeat items from prior versions. Now finds the previous version bump commit and uses it as the range start. Also regenerated CHANGELOG.md from scratch to remove all accumulated duplicates (~1600 lines). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 16b6b51 commit 42bc180

File tree

2 files changed

+113
-1650
lines changed

2 files changed

+113
-1650
lines changed

.github/scripts/generate-changelog.sh

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,25 @@ if [ -z "$OLD_VERSION" ]; then
2929
fi
3030
fi
3131

32-
# Determine git range for commits
33-
# Get the last 50 commits and filter later
34-
GIT_RANGE="HEAD~50..HEAD"
32+
# Determine git range: from the last version bump commit to HEAD
33+
# This ensures each version only includes commits new since the previous release
34+
GIT_RANGE=""
35+
if [ -n "$OLD_VERSION" ]; then
36+
# Find the commit that bumped TO the old version (e.g., "bump version X -> 1.16.0")
37+
LAST_BUMP_COMMIT=$(git log --all --grep="bump version.*-> $OLD_VERSION" --format="%H" -1 2>/dev/null || true)
38+
if [ -n "$LAST_BUMP_COMMIT" ]; then
39+
GIT_RANGE="$LAST_BUMP_COMMIT..HEAD"
40+
fi
41+
fi
42+
43+
# Fallback: if no bump commit found, use all commits (first release scenario)
44+
if [ -z "$GIT_RANGE" ]; then
45+
GIT_RANGE="HEAD"
46+
fi
3547

3648
# Get commits for this path, excluding version bump commits and website changes
3749
COMMITS=$(git log $GIT_RANGE --pretty=format:"%h|%s|%an|%ad" --date=short -- "$PATH_DIR" ':!website' 2>/dev/null | grep -v "\[skip ci\]" | grep -v "chore(release):" | grep -v "chore(plugin): bump" || true)
3850

39-
# If we still don't have commits, try without range limit
40-
if [ -z "$COMMITS" ]; then
41-
COMMITS=$(git log --all --pretty=format:"%h|%s|%an|%ad" --date=short -- "$PATH_DIR" ':!website' 2>/dev/null | grep -v "\[skip ci\]" | grep -v "chore(release):" | grep -v "chore(plugin): bump" | head -20 || true)
42-
fi
43-
4451
if [ -z "$COMMITS" ]; then
4552
echo "No commits found for $PATH_DIR in range $GIT_RANGE"
4653
exit 0
@@ -143,10 +150,11 @@ if [ -n "$OTHER" ]; then
143150
} >>"$TEMP_FILE"
144151
fi
145152

146-
# If existing changelog exists, append old entries (excluding the header)
153+
# If existing changelog exists, append old entries (excluding the header and [Unreleased] section)
147154
if [ -f "$CHANGELOG_FILE" ]; then
148-
# Skip the first 6 lines (header) and append the rest
149-
tail -n +7 "$CHANGELOG_FILE" >>"$TEMP_FILE" 2>/dev/null || true
155+
# Skip header (first 6 lines), then strip any [Unreleased] section
156+
# (its commits are now captured in the new version's range)
157+
tail -n +7 "$CHANGELOG_FILE" 2>/dev/null | sed '/^## \[Unreleased\]/,/^## \[/{ /^## \[Unreleased\]/d; /^## \[/!d; }' >>"$TEMP_FILE" || true
150158
fi
151159

152160
# Remove consecutive blank lines and ensure single trailing newline

0 commit comments

Comments
 (0)