-
-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathdangerfile-utils.js
More file actions
79 lines (72 loc) · 1.62 KB
/
dangerfile-utils.js
File metadata and controls
79 lines (72 loc) · 1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/// Unified configuration for PR flavors (based on real Sentry usage analysis)
const FLAVOR_CONFIG = [
{
labels: ["feat", "feature"],
changelog: "Features",
isFeature: true
},
{
labels: ["fix", "bug", "bugfix"],
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"
]
}
];
/// Get flavor configuration for a given PR flavor
function getFlavorConfig(prFlavor) {
const normalizedFlavor = prFlavor.toLowerCase().trim();
// Strip scope/context from conventional commit format: "type(scope)" -> "type"
const baseType = normalizedFlavor.replace(/\([^)]*\)/, '');
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) {
if (prTitle) {
const parts = prTitle.split(":");
if (parts.length > 1) {
return parts[0].toLowerCase().trim();
}
}
if (prBranchRef) {
const parts = prBranchRef.split("/");
if (parts.length > 1) {
return parts[0].toLowerCase();
}
}
return "";
}
module.exports = {
FLAVOR_CONFIG,
getFlavorConfig,
extractPRFlavor
};