-
-
Notifications
You must be signed in to change notification settings - Fork 8
feat: improve Danger testing and flavor recognition #105
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
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
a845daf
feat: enhance Danger with inline changelog suggestions
vaind c5efc86
Potential fix for code scanning alert no. 22: Workflow does not conta…
vaind 30f76ee
fix: download dangerfile-utils.js in danger workflow
vaind 0b46341
refactor: consolidate skip-changelog flavors into single config
vaind c9b647c
refactor: simplify dangerfile to focus on testing and flavor improvem…
vaind 115b0fb
feat: update flavor config based on real Sentry usage analysis
vaind 87b4e12
feat: improve Danger testing and conventional commit scope handling
vaind dbd642e
refactor: remove unused findChangelogInsertionPoint function and its …
vaind a5c9a66
refactor: remove unrelated function and add input validation
vaind 0a63fca
security: replace ReDoS-vulnerable regex with safe string parsing
vaind 4db5d95
feat: enhance flavor configuration and add tests for non-conventional…
vaind File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| /// Unified configuration for PR flavors (based on real Sentry usage analysis) | ||
| const FLAVOR_CONFIG = [ | ||
| { | ||
| labels: ["feat", "feature", "add", "implement"], | ||
| changelog: "Features", | ||
| isFeature: true | ||
| }, | ||
| { | ||
| labels: ["fix", "bug", "bugfix", "resolve", "correct"], | ||
| changelog: "Fixes" | ||
| }, | ||
| { | ||
| labels: ["sec", "security"], | ||
| changelog: "Security" | ||
| }, | ||
| { | ||
| labels: ["perf", "performance"], | ||
| changelog: "Performance" | ||
| }, | ||
| { | ||
| // Internal changes - no changelog needed | ||
| changelog: undefined, | ||
| labels: [ | ||
| "docs", | ||
| "doc", | ||
| "style", | ||
| "ref", | ||
| "refactor", | ||
| "tests", | ||
| "test", | ||
| "build", | ||
| "ci", | ||
| "chore", | ||
| "meta", | ||
| "deps", | ||
| "dep", | ||
| "update", | ||
| "bump", | ||
| "cleanup", | ||
| "format" | ||
| ] | ||
| } | ||
| ]; | ||
|
|
||
| /// Get flavor configuration for a given PR flavor | ||
| function getFlavorConfig(prFlavor) { | ||
| const normalizedFlavor = prFlavor.toLowerCase().trim(); | ||
vaind marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| // Strip scope/context from conventional commit format: "type(scope)" -> "type" | ||
| const parenIndex = normalizedFlavor.indexOf('('); | ||
| const baseType = parenIndex !== -1 ? normalizedFlavor.substring(0, parenIndex) : normalizedFlavor; | ||
|
|
||
| const config = FLAVOR_CONFIG.find(config => | ||
| config.labels.includes(normalizedFlavor) || config.labels.includes(baseType) | ||
| ); | ||
|
|
||
| return config || { | ||
| changelog: "Features" // Default to Features | ||
| }; | ||
| } | ||
|
|
||
|
|
||
| /// Extract PR flavor from title or branch name | ||
| function extractPRFlavor(prTitle, prBranchRef) { | ||
| // Validate input parameters to prevent runtime errors | ||
| if (prTitle && typeof prTitle === 'string') { | ||
| // First try conventional commit format: "type(scope): description" | ||
| const colonParts = prTitle.split(":"); | ||
| if (colonParts.length > 1) { | ||
| return colonParts[0].toLowerCase().trim(); | ||
| } | ||
|
|
||
| // Fallback: try first word for non-conventional titles like "fix memory leak" | ||
| const firstWord = prTitle.trim().split(/\s+/)[0]; | ||
| if (firstWord) { | ||
| return firstWord.toLowerCase(); | ||
| } | ||
| } | ||
|
|
||
| if (prBranchRef && typeof prBranchRef === 'string') { | ||
| const parts = prBranchRef.split("/"); | ||
| if (parts.length > 1) { | ||
| return parts[0].toLowerCase(); | ||
| } | ||
| } | ||
| return ""; | ||
| } | ||
|
|
||
| module.exports = { | ||
| FLAVOR_CONFIG, | ||
| getFlavorConfig, | ||
| extractPRFlavor | ||
| }; | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.