Skip to content

Commit 15c7b5d

Browse files
justin808claude
andauthored
Improve update-changelog command with better git workflow (#1961)
## Summary Ports enhancements from Shakapacker PR #824 to improve the `/update-changelog` slash command: - **Explicit git fetch step**: Always fetch `origin/master` first to ensure latest commits are available - **Consistent origin/master usage**: Use `origin/master` instead of local `master` throughout to avoid missing recently merged PRs - **Automatic PR extraction**: Use grep to extract ALL PR numbers from commit history automatically - **PR existence checking**: Check if PRs are already documented before adding duplicates - **Version links documentation**: Add detailed instructions for managing version comparison links - **Simplified linting**: Use just `yarn lint` instead of multiple commands - **Better change identification**: Provide keyword hints for identifying user-visible changes ## Test plan - [x] Review the updated command documentation - [x] Verify formatting with Prettier - [x] Confirm pre-commit hooks pass - [ ] Test the command with actual changelog updates 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- Reviewable:start --> - - - This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/shakacode/react_on_rails/1961) <!-- Reviewable:end --> Co-authored-by: Claude <[email protected]>
1 parent ee80bc2 commit 15c7b5d

File tree

1 file changed

+46
-20
lines changed

1 file changed

+46
-20
lines changed

.claude/commands/update-changelog.md

Lines changed: 46 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -95,60 +95,86 @@ This will:
9595
- Add headers for the new version
9696
- Update version diff links at the bottom of the file
9797

98+
### Version Links
99+
100+
After adding an entry to the `## [Unreleased]` section, ensure the version diff links at the bottom of the file are correct.
101+
102+
The format at the bottom should be:
103+
104+
```markdown
105+
[Unreleased]: https://github.com/shakacode/react_on_rails/compare/v16.0.0...master
106+
[v16.0.0]: https://github.com/shakacode/react_on_rails/compare/v15.0.0...v16.0.0
107+
```
108+
109+
When a new version is released:
110+
111+
1. Change `[Unreleased]` heading to `## [vX.Y.Z] - Month Day, Year`
112+
2. Add a new `## [Unreleased]` section at the top
113+
3. Update the `[Unreleased]` link to compare from the new version
114+
4. Add a new version link for the released version
115+
98116
## Process
99117

100118
### For Regular Changelog Updates
101119

102-
1. **Determine the correct version tag to compare against**:
120+
1. **ALWAYS fetch latest changes first**:
121+
122+
- **CRITICAL**: Run `git fetch origin master` to ensure you have the latest commits
123+
- The workspace may be behind origin/master, causing you to miss recently merged PRs
124+
- After fetching, use `origin/master` for all comparisons, NOT local `master` branch
125+
126+
2. **Determine the correct version tag to compare against**:
103127

104128
- First, check the tag dates: `git log --tags --simplify-by-decoration --pretty="format:%ai %d" | head -10`
105129
- Find the latest version tag and its date
106-
- Compare main branch date to the tag date
107-
- If the tag is NEWER than main, it means main needs to be updated to include the tag's commits
130+
- Compare origin/master branch date to the tag date
131+
- If the tag is NEWER than origin/master, it means the branch needs to be updated to include the tag's commits
108132
- **CRITICAL**: Always use `git log TAG..BRANCH` to find commits that are in the tag but not in the branch, as the tag may be ahead
109133

110-
2. **Check commits and version boundaries**:
134+
3. **Check commits and version boundaries**:
111135

112-
- Run `git log --oneline LAST_TAG..master` to see commits since the last release
113-
- Also check `git log --oneline master..LAST_TAG` to see if the tag is ahead of master
136+
- **IMPORTANT**: Use `origin/master` in all commands below, not local `master`
137+
- Run `git log --oneline LAST_TAG..origin/master` to see commits since the last release
138+
- Also check `git log --oneline origin/master..LAST_TAG` to see if the tag is ahead of origin/master
114139
- If the tag is ahead, entries in "Unreleased" section may actually belong to that tagged version
115-
- Identify which commits contain user-visible changes
116-
- Extract PR numbers and author information from commit messages
117-
- **Never ask the user for PR details** - get them from the git history
140+
- **Extract ALL PR numbers** from commit messages using grep: `git log --oneline LAST_TAG..origin/master | grep -oE "#[0-9]+" | sort -u`
141+
- For each PR number found, check if it's already in CHANGELOG.md using: `grep "PR XXX" CHANGELOG.md` (note: no hash in search since React on Rails uses no hash)
142+
- Identify which commits contain user-visible changes (look for keywords like "Fix", "Add", "Feature", "Bug", etc.)
143+
- Extract author information from commit messages
144+
- **Never ask the user for PR details** - get them from the git history or use WebFetch on the PR URL
118145

119-
3. **Validate** that changes are user-visible (per the criteria above). If not user-visible, skip those commits.
146+
4. **Validate** that changes are user-visible (per the criteria above). If not user-visible, skip those commits.
120147

121-
4. **Read the current CHANGELOG.md** to understand the existing structure and formatting.
148+
5. **Read the current CHANGELOG.md** to understand the existing structure and formatting.
122149

123-
5. **Determine where entries should go**:
150+
6. **Determine where entries should go**:
124151

125-
- If the latest version tag is NEWER than master branch, move entries from "Unreleased" to that version section
126-
- If master is ahead of the latest tag, add new entries to "Unreleased"
152+
- If the latest version tag is NEWER than origin/master branch, move entries from "Unreleased" to that version section
153+
- If origin/master is ahead of the latest tag, add new entries to "Unreleased"
127154
- Always verify the version date in CHANGELOG.md matches the actual tag date
128155

129-
6. **Add or move entries** to the appropriate section under appropriate category headings.
156+
7. **Add or move entries** to the appropriate section under appropriate category headings.
130157

131158
- **CRITICAL**: When moving entries from "Unreleased" to a version section, merge them with existing entries under the same category heading
132159
- **NEVER create duplicate section headings** (e.g., don't create two "### Fixed" sections)
133160
- If the version section already has a category heading (e.g., "### Fixed"), add the moved entries to that existing section
134161
- Maintain the category order as defined above
135162

136-
7. **Verify formatting**:
163+
8. **Verify formatting**:
137164

138165
- Bold description with period
139166
- Proper PR link (NO hash symbol)
140167
- Proper author link
141168
- Consistent with existing entries
142169
- File ends with a newline character
143170

144-
8. **Run linting** after making changes:
171+
9. **Run linting** after making changes:
145172

146173
```bash
147-
bundle exec rubocop
148-
yarn run lint
174+
yarn lint
149175
```
150176

151-
9. **Show the user** the added or moved entries and explain what was done.
177+
10. **Show the user** the added or moved entries and explain what was done.
152178

153179
### For Beta to Non-Beta Version Release
154180

0 commit comments

Comments
 (0)