[webhooks] additional action keywords#40
Conversation
|
Warning Review limit reached
Next review available in: 50 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughExtended the commit-message keyword auto-transition logic in internal/webhooks/domain.go by adding single-verb keyword forms ("fix", "resolve", "close", "block") to the keywordActions mapping and broadening the keywordRefPattern regex to also match these forms plus the "on hold" phrase. ChangesKeyword Auto-Transition Parsing
Estimated code review effort: 1 (Trivial) | ~5 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
internal/webhooks/domain.go (1)
46-46: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winConsider deriving the regex from the
keywordActionsmap keys to avoid manual sync.The keyword list is duplicated between
keywordActions(line 21) andkeywordRefPattern(line 46). If a keyword is added to one but not the other, the regex may capture a keyword with no matching action (producing a zero-valueKeywordAction{Status: ""}), or the map may contain an entry that never matches. Building the alternation fromsorted(map.Keys(keywordActions))at init time eliminates this risk.♻️ Suggested refactor: build regex from map keys
var keywordActions = map[string]KeywordAction{ "fix": {Status: tasks.StatusResolved, Verb: verbResolved}, "fixes": {Status: tasks.StatusResolved, Verb: verbResolved}, "fixed": {Status: tasks.StatusResolved, Verb: verbResolved}, "resolve": {Status: tasks.StatusResolved, Verb: verbResolved}, "resolves": {Status: tasks.StatusResolved, Verb: verbResolved}, "resolved": {Status: tasks.StatusResolved, Verb: verbResolved}, "close": {Status: tasks.StatusClosed, Verb: verbClosed}, "closes": {Status: tasks.StatusClosed, Verb: verbClosed}, "closed": {Status: tasks.StatusClosed, Verb: verbClosed}, "block": {Status: tasks.StatusOnHold, Verb: verbOnHold}, "blocks": {Status: tasks.StatusOnHold, Verb: verbOnHold}, "blocked": {Status: tasks.StatusOnHold, Verb: verbOnHold}, "on hold": {Status: tasks.StatusOnHold, Verb: verbOnHold}, } +// buildKeywordPattern constructs the keyword alternation from keywordActions keys, +// sorting by descending length so longer alternatives (e.g. "fixes") are tried +// before shorter prefixes (e.g. "fix"). +func buildKeywordPattern() string { + keys := make([]string, 0, len(keywordActions)) + for k := range keywordActions { + keys = append(keys, k) + } + sort.Sort(sort.Reverse(byLen(keys))) + return `(?i)\b(` + strings.Join(keys, "|") + `)\s+#(\d+)\b` +} + +type byLen []string + +func (b byLen) Len() int { return len(b) } +func (b byLen) Less(i, j int) bool { return len(b[i]) < len(b[j]) } +func (b byLen) Swap(i, j int) { b[i], b[j] = b[j], b[i] } + var ( // ... other vars ... - keywordRefPattern = regexp.MustCompile( - `(?i)\b(fix|fixes|fixed|resolve|resolves|resolved|close|closes|closed|block|blocks|blocked|on hold)\s+#(\d+)\b`, - ) + keywordRefPattern = regexp.MustCompile(buildKeywordPattern()) )🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@internal/webhooks/domain.go` at line 46, The keyword list for issue references is duplicated between keywordActions and keywordRefPattern, so update the regex construction to derive its alternation from the keywordActions map keys instead of hardcoding the keywords. Use the existing keywordActions symbol to build keywordRefPattern at init time from sorted keys so both stay in sync and every matched keyword always has a corresponding KeywordAction.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@internal/webhooks/domain.go`:
- Line 46: Add parser coverage for the new reference keywords in domain parsing
so `ParsedReference.Status` and `ParsedReference.Verb` can’t regress unnoticed.
Update the tests around the reference parsing logic in
`ParsedReference`/`ParseReference` to include `fix`, `resolve`, `close`,
`block`, and `on hold` variants, asserting both the parsed status and verb for
each form. Keep the tests aligned with the keyword regex in `domain.go` so
future changes to that pattern are caught.
---
Nitpick comments:
In `@internal/webhooks/domain.go`:
- Line 46: The keyword list for issue references is duplicated between
keywordActions and keywordRefPattern, so update the regex construction to derive
its alternation from the keywordActions map keys instead of hardcoding the
keywords. Use the existing keywordActions symbol to build keywordRefPattern at
init time from sorted keys so both stay in sync and every matched keyword always
has a corresponding KeywordAction.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 42cd6531-4e9c-4a75-aafa-34f59065bdcc
📒 Files selected for processing (1)
internal/webhooks/domain.go
🤖 Pull request artifacts
|
5a81c62 to
afb9ef7
Compare
Summary by CodeRabbit