-
-
Notifications
You must be signed in to change notification settings - Fork 8
feat: Danger - Add inline changelog suggestions for GitHub PRs #107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Implements GitHub Issue #45 by replacing generic markdown instructions with inline GitHub suggestions that users can apply with one click. Changes: - Add findChangelogInsertionPoint() to parse CHANGELOG.md structure - Add generateChangelogSuggestion() to create formatted suggestions - Update reportMissingChangelog() to use GitHub PR review comments API - Maintain backward compatibility with fallback to markdown instructions - Add comprehensive test suite (34 tests) covering edge cases Users will now see precise inline suggestions instead of copy-paste instructions, improving developer experience for changelog management. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Instructions and example for changelogPlease add an entry to Example: ## Unreleased
### Features
- Danger - Add inline changelog suggestions for GitHub PRs ([#107](https://github.com/getsentry/github-workflows/pull/107))If none of the above apply, you can opt out of this check by adding |
Enhanced changelog insertion logic to handle all possible scenarios: - **No UNRELEASED section**: Creates full "## Unreleased\n### Section\n- Entry" - **UNRELEASED but no subsection**: Creates "### Section\n- Entry" - **Both exist**: Just adds "- Entry" Changes: - Refactored findChangelogInsertionPoint() to return insertContent type - Updated generateChangelogSuggestion() with switch statement for content types - Added 8 new edge case tests (43 total tests, all passing) - Handles empty changelogs, missing sections, mixed case headers This makes the feature work with any changelog state, not just existing structured changelogs. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Adds changelog entry for PR #107 implementing GitHub Issue #45. This should resolve the Danger CI failure requesting a changelog entry. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
ddb7bac to
c4e607f
Compare
GitHub PR review comments API can only target files that are part of the PR diff. When CHANGELOG.md is not modified in the PR, we cannot create inline suggestions and must fall back to markdown instructions. Changes: - Check if changelogFile is in danger.git modified/created/deleted files - Fall back to markdown instructions when file not in diff - Add warning log explaining why inline suggestions cannot be used This fixes the CI error: "could not be resolved" for pull_request_review_thread.path 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
|
Closing this PR after discovering fundamental limitations that make the inline suggestions feature impractical for real-world use. Issues Discovered1. GitHub API Limitation: Files Must Be in PR DiffThe GitHub PR review comments API can only create suggestions on files that are part of the PR's changed files. This means:
2. Permission Issues with GitHub APIWhen attempting to use the GitHub API for suggestions:
AnalysisThe core idea was sound - replace copy-paste instructions with one-click suggestions. However, the GitHub API constraints make this feature work only in edge cases: When it works: PR already modifies Since the vast majority of PRs don't touch the changelog file, this feature would rarely provide value over the existing markdown instructions. Implementation QualityThe code implementation itself was solid:
But good implementation can't overcome fundamental API limitations. RecommendationKeep the existing markdown instructions approach. It works reliably across all scenarios and doesn't require special permissions or API constraints. Thanks for the learning experience in exploring GitHub's API boundaries! 🤖 Closes #45 as not feasible due to GitHub API limitations. |
Summary
Implements GitHub Issue #45 by replacing generic markdown instructions with inline GitHub suggestions that users can apply with one click.
Changes Made
Core Implementation
findChangelogInsertionPoint(): Parses CHANGELOG.md to find exact line numbers and determines content type neededgenerateChangelogSuggestion(): Creates properly formatted suggestion text based on what needs to be insertedreportMissingChangelog(): Usesdanger.github.api.rest.pulls.createReviewComment()to create inline suggestionsKey Features ✨
Flexible Insertion Logic
The implementation now handles three content scenarios:
unreleased-and-section: No UNRELEASED section existssection-and-entry: UNRELEASED exists but subsection doesn'tentry-only: Both UNRELEASED and subsection existComprehensive Testing
Before vs After
Current Behavior (❌)
New Behavior (✅)
For existing structured changelog:
For completely new changelog:
With "Apply suggestion" button for one-click changelog updates
Test Plan
Implementation Notes
\``suggestion`)Closes #45
🤖 Generated with Claude Code