Conversation
WalkthroughAdded documentation for a new optional OpenCommit config key OCO_OMIT_SCOPE and updated a GitHub Actions PR-title-to-label mapping (replaced 'doc' key with 'docs' → 'documentation'). Changes are documentation and CI workflow config only; no runtime code changes. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
✨ Finishing touches🧪 Generate unit tests
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 Pre-merge checks✅ Passed checks (3 passed)
|
There was a problem hiding this comment.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
.github/workflows/pr-auto-label.yml (1)
47-55: Handle Conventional Commit scopes (e.g., "docs(ui): ...").Current normalization doesn't strip "(scope)", so keywords won’t match. Strip optional scope before lookup.
- for (const word of words) { - const normalizedWord = word.toLowerCase().replace(/^[\W_]+|[\W_]+$/g, ''); - - if (keywordMap.hasOwnProperty(normalizedWord)) { - labelsToAdd.add(keywordMap[normalizedWord]); + for (const word of words) { + const normalizedWord = word.toLowerCase().replace(/^[\W_]+|[\W_]+$/g, ''); + const typeOnly = normalizedWord.replace(/\(.*$/, ''); // drop optional "(scope" + + if (keywordMap.hasOwnProperty(typeOnly)) { + labelsToAdd.add(keywordMap[typeOnly]); break; // 找到第一个匹配就停止 } }
🧹 Nitpick comments (3)
.github/workflows/pr-auto-label.yml (3)
33-35: Keep backward compatibility: map both "docs" and "doc".Dropping "doc" breaks existing PR title conventions (e.g., "doc: ..."). Add an alias to avoid regressions.
'improvement': 'enhancement', - 'docs': 'documentation', + 'docs': 'documentation', + 'doc': 'documentation', 'readme': 'documentation',
57-72: Don’t remove unrelated labels; only manage the label set this workflow owns.
removeAllLabelscan wipe manually applied labels. Remove only labels this workflow controls.- // 首先清除所有现有标签 - try { - await github.rest.issues.removeAllLabels({ - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo - }); - console.log('All existing labels removed'); - } catch (error) { - console.log('Error removing labels:', error.message); - } + // 仅移除由该工作流管理的标签,避免误删其他标签 + const managed = new Set(Object.values(keywordMap)); + const existing = (context.payload.pull_request.labels || []).map(l => l.name); + const toRemove = existing.filter(name => managed.has(name)); + for (const name of toRemove) { + try { + await github.rest.issues.removeLabel({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + name, + }); + } catch (error) { + console.log(`Error removing label ${name}:`, error.message); + } + }
3-9: Forked PRs won’t get labels withpull_request+ write perms.If you need labeling on forked PRs, consider
pull_request_target(with care) so the token has write on the base repo. Keep the script minimal and avoid using fork-supplied code/inputs to mitigate risk.
Summary by CodeRabbit
Documentation
Chores