@rmartz/pr-policy 0.10.1 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/bin/pr-policy.js
CHANGED
|
@@ -708,15 +708,15 @@ function pipVersions(text) {
|
|
|
708
708
|
}
|
|
709
709
|
return versions;
|
|
710
710
|
}
|
|
711
|
-
function
|
|
711
|
+
function manifestVersions(path, text) {
|
|
712
712
|
return basename(path) === "package.json" ? npmVersions(text) : pipVersions(text);
|
|
713
713
|
}
|
|
714
714
|
function sensitiveBumps(changes) {
|
|
715
715
|
const bumped = /* @__PURE__ */ new Set();
|
|
716
716
|
for (const change of changes) {
|
|
717
717
|
if (change.baseText === void 0 || change.headText === void 0) continue;
|
|
718
|
-
const before =
|
|
719
|
-
const after =
|
|
718
|
+
const before = manifestVersions(change.path, change.baseText);
|
|
719
|
+
const after = manifestVersions(change.path, change.headText);
|
|
720
720
|
if (before === null || after === null) continue;
|
|
721
721
|
for (const name of CI_SENSITIVE_PACKAGES) {
|
|
722
722
|
const was = before.get(name);
|
|
@@ -1156,6 +1156,34 @@ function isReleasePleaseTitle(title) {
|
|
|
1156
1156
|
return RELEASE_PLEASE_TITLE.test(title);
|
|
1157
1157
|
}
|
|
1158
1158
|
|
|
1159
|
+
// src/checks/title/major-bump.ts
|
|
1160
|
+
var LEADING_VERSION = /^[\^~=<>!v\s]*(\d+)(?:\.(\d+))?(?:\.(\d+))?/;
|
|
1161
|
+
function parseVersion(spec) {
|
|
1162
|
+
const match = LEADING_VERSION.exec(spec);
|
|
1163
|
+
if (match === null) return void 0;
|
|
1164
|
+
const [, major = "0", minor = "0", patch = "0"] = match;
|
|
1165
|
+
return { major: Number(major), text: `${major}.${minor}.${patch}` };
|
|
1166
|
+
}
|
|
1167
|
+
function majorBumps(changes) {
|
|
1168
|
+
const bumps = /* @__PURE__ */ new Set();
|
|
1169
|
+
for (const change of changes) {
|
|
1170
|
+
if (change.baseText === void 0 || change.headText === void 0) continue;
|
|
1171
|
+
const before = manifestVersions(change.path, change.baseText);
|
|
1172
|
+
const after = manifestVersions(change.path, change.headText);
|
|
1173
|
+
if (before === null || after === null) continue;
|
|
1174
|
+
for (const [name, spec] of after) {
|
|
1175
|
+
const was = before.get(name);
|
|
1176
|
+
if (was === void 0) continue;
|
|
1177
|
+
const from = parseVersion(was);
|
|
1178
|
+
const to = parseVersion(spec);
|
|
1179
|
+
if (from !== void 0 && to !== void 0 && to.major > from.major) {
|
|
1180
|
+
bumps.add(`${name} ${from.text} \u2192 ${to.text}`);
|
|
1181
|
+
}
|
|
1182
|
+
}
|
|
1183
|
+
}
|
|
1184
|
+
return [...bumps];
|
|
1185
|
+
}
|
|
1186
|
+
|
|
1159
1187
|
// src/checks/title/type-paths.ts
|
|
1160
1188
|
function isMarkdownPath(path) {
|
|
1161
1189
|
return path.toLowerCase().endsWith(".md");
|
|
@@ -1208,6 +1236,7 @@ function decideTitle(pr) {
|
|
|
1208
1236
|
}
|
|
1209
1237
|
const findings = [];
|
|
1210
1238
|
const functional = isFunctionalType(title.type);
|
|
1239
|
+
const breakingTitle = `${title.type}${title.scope ? `(${title.scope})` : ""}!: ${title.subject}`;
|
|
1211
1240
|
const breakingLabel = labels.has(BREAKING_CHANGE_LABEL);
|
|
1212
1241
|
const breakingIntent = breakingLabel || labels.has(HOTFIX_LABEL);
|
|
1213
1242
|
if (!functional) {
|
|
@@ -1228,7 +1257,7 @@ function decideTitle(pr) {
|
|
|
1228
1257
|
} else if (breakingIntent && !title.breaking) {
|
|
1229
1258
|
findings.push(
|
|
1230
1259
|
block2(
|
|
1231
|
-
`The PR is labelled breaking but the title has no \`!\`, so the release would miss the major. Retitle to \`${
|
|
1260
|
+
`The PR is labelled breaking but the title has no \`!\`, so the release would miss the major. Retitle to \`${breakingTitle}\`.`
|
|
1232
1261
|
)
|
|
1233
1262
|
);
|
|
1234
1263
|
} else if (!breakingIntent && title.breaking) {
|
|
@@ -1238,6 +1267,14 @@ function decideTitle(pr) {
|
|
|
1238
1267
|
)
|
|
1239
1268
|
);
|
|
1240
1269
|
}
|
|
1270
|
+
const majors = majorBumps(pr.manifestChanges);
|
|
1271
|
+
if (functional && !breakingIntent && !title.breaking && majors.length > 0) {
|
|
1272
|
+
findings.push(
|
|
1273
|
+
block2(
|
|
1274
|
+
`This PR bumps a dependency's major version (${majors.map((bump) => `\`${bump}\``).join(", ")}), so it is a breaking change. Retitle to \`${breakingTitle}\` and add the \`${BREAKING_CHANGE_LABEL}\` label.`
|
|
1275
|
+
)
|
|
1276
|
+
);
|
|
1277
|
+
}
|
|
1241
1278
|
const pathViolation = typePathViolation(title.type, pr.changedFiles);
|
|
1242
1279
|
if (pathViolation !== void 0) findings.push(block2(pathViolation));
|
|
1243
1280
|
const mayRetitle = !functional && title.type !== "ci";
|
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rmartz/pr-policy",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"description": "Read-only PR content classifiers — CI-change classification, title-type rules, and more — reported as one blocking pr-policy check-run. Distributed as a pinned Action kept current by Dependabot.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pr-policy",
|