pull-request-split-advisor 3.2.12 → 3.2.14
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/cli.js +10 -8
- package/dist/core/blocks.js +57 -0
- package/dist/output/report.js +3 -3
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -399,9 +399,18 @@ async function main() {
|
|
|
399
399
|
], "red");
|
|
400
400
|
// ─── Estado de la cascada en terminal ───────────────────────────────────
|
|
401
401
|
ui.section("ESTADO DE LA CASCADA", "#");
|
|
402
|
+
// Rama actual primero (#1)
|
|
403
|
+
ui.subsection(`#1 ${currentBranch} ✔ rama actual`);
|
|
404
|
+
if (currentBranchCommits.length === 0) {
|
|
405
|
+
ui.muted(" Sin commits detectados.");
|
|
406
|
+
}
|
|
407
|
+
else {
|
|
408
|
+
ui.table(["SHA", "Mensaje"], currentBranchCommits.map((c) => [c.sha, c.subject]), true);
|
|
409
|
+
}
|
|
410
|
+
// Ramas hermanas a continuación (#2, #3, …)
|
|
402
411
|
for (let i = 0; i < siblings.length; i++) {
|
|
403
412
|
const sibling = siblings[i];
|
|
404
|
-
ui.subsection(`#${i +
|
|
413
|
+
ui.subsection(`#${i + 2} ${sibling.name}`);
|
|
405
414
|
if (sibling.commits.length === 0) {
|
|
406
415
|
ui.muted(" Sin commits detectados.");
|
|
407
416
|
}
|
|
@@ -409,13 +418,6 @@ async function main() {
|
|
|
409
418
|
ui.table(["SHA", "Mensaje"], sibling.commits.map((c) => [c.sha, c.subject]), true);
|
|
410
419
|
}
|
|
411
420
|
}
|
|
412
|
-
ui.subsection(`#${siblings.length + 1} ${currentBranch} ✔ rama actual`);
|
|
413
|
-
if (currentBranchCommits.length === 0) {
|
|
414
|
-
ui.muted(" Sin commits detectados.");
|
|
415
|
-
}
|
|
416
|
-
else {
|
|
417
|
-
ui.table(["SHA", "Mensaje"], currentBranchCommits.map((c) => [c.sha, c.subject]), true);
|
|
418
|
-
}
|
|
419
421
|
}
|
|
420
422
|
// ─── Pipeline de análisis ────────────────────────────────────────────────
|
|
421
423
|
ui.spinner.start("Analizando cambios del working tree...");
|
package/dist/core/blocks.js
CHANGED
|
@@ -132,6 +132,63 @@ export function buildBlocks(fileStats, config, deps) {
|
|
|
132
132
|
depScore: 0
|
|
133
133
|
});
|
|
134
134
|
}
|
|
135
|
+
// ── Post-proceso: fusionar bloques de solo-tests con su bloque fuente ──────
|
|
136
|
+
// Cubre el caso en que test y fuente están en directorios distintos
|
|
137
|
+
// (ej: `tests/` vs `src/`) y getGroupKey los asigna a bloques distintos.
|
|
138
|
+
// Regla: un test no puede ir a una rama sin su fuente, salvo que la fuente
|
|
139
|
+
// no tenga cambios y no esté en el conjunto analizado.
|
|
140
|
+
{
|
|
141
|
+
const linesByPath = new Map(fileStats.map((f) => [f.path, f.lines]));
|
|
142
|
+
// Índice: nombre-base del fuente → bloque que lo contiene.
|
|
143
|
+
const sourceBlockByBaseName = new Map();
|
|
144
|
+
for (const block of blocks) {
|
|
145
|
+
for (const f of block.files) {
|
|
146
|
+
if (!isTestFile(f)) {
|
|
147
|
+
const baseName = basename(f).replace(/\.[^.]+$/, "").replace(/\.?(test|spec)$/, "");
|
|
148
|
+
if (!sourceBlockByBaseName.has(baseName)) {
|
|
149
|
+
sourceBlockByBaseName.set(baseName, block);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
// Para cada bloque que contiene exclusivamente tests, intentar fusionarlo
|
|
155
|
+
// con el bloque de su archivo fuente si éste tiene cambios.
|
|
156
|
+
const blocksToDelete = new Set();
|
|
157
|
+
for (const block of blocks) {
|
|
158
|
+
if (blocksToDelete.has(block))
|
|
159
|
+
continue;
|
|
160
|
+
if (!block.files.every((f) => isTestFile(f)))
|
|
161
|
+
continue; // ya tiene fuente: OK
|
|
162
|
+
const moved = [];
|
|
163
|
+
for (const testFile of block.files) {
|
|
164
|
+
const testBase = basename(testFile)
|
|
165
|
+
.replace(/\.[^.]+$/, "")
|
|
166
|
+
.replace(/\.?(test|spec)$/, "")
|
|
167
|
+
.replace(/^test_/, "")
|
|
168
|
+
.replace(/_test$/, "");
|
|
169
|
+
const sourceBlock = sourceBlockByBaseName.get(testBase);
|
|
170
|
+
if (!sourceBlock || sourceBlock === block)
|
|
171
|
+
continue;
|
|
172
|
+
// Fusionar el test en el bloque del fuente.
|
|
173
|
+
sourceBlock.files.push(testFile);
|
|
174
|
+
sourceBlock.lines += linesByPath.get(testFile) ?? 0;
|
|
175
|
+
sourceBlock.divisible = false; // test + fuente → siempre indivisible
|
|
176
|
+
moved.push(testFile);
|
|
177
|
+
}
|
|
178
|
+
if (moved.length === block.files.length) {
|
|
179
|
+
// Todos los tests fueron reasignados: eliminar este bloque vacío.
|
|
180
|
+
blocksToDelete.add(block);
|
|
181
|
+
}
|
|
182
|
+
else if (moved.length > 0) {
|
|
183
|
+
// Quitar solo los archivos que se movieron.
|
|
184
|
+
block.files = block.files.filter((f) => !moved.includes(f));
|
|
185
|
+
block.lines = block.files.reduce((sum, f) => sum + (linesByPath.get(f) ?? 0), 0);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
if (blocksToDelete.size > 0) {
|
|
189
|
+
blocks.splice(0, blocks.length, ...blocks.filter((b) => !blocksToDelete.has(b)));
|
|
190
|
+
}
|
|
191
|
+
}
|
|
135
192
|
// Calcular depScore con un mapa de frecuencias: O(n+m) en lugar de O(n×m).
|
|
136
193
|
const fileEdgeCount = new Map();
|
|
137
194
|
for (const { from, to } of deps) {
|
package/dist/output/report.js
CHANGED
|
@@ -506,8 +506,8 @@ export function renderHtmlReport(input) {
|
|
|
506
506
|
Para mantener el orden correcto de PRs apilados, la nueva rama debe crearse desde esa rama.`
|
|
507
507
|
: `No se encontraron otras ramas de la misma cascada. Crea la nueva rama directamente desde la base.`;
|
|
508
508
|
const allBranches = [
|
|
509
|
-
|
|
510
|
-
|
|
509
|
+
{ name: currentBranch, commits: cw.currentBranchCommits, isCurrent: true },
|
|
510
|
+
...cw.siblings
|
|
511
511
|
];
|
|
512
512
|
const cascadeStateHtml = allBranches.map((branch, idx) => {
|
|
513
513
|
const num = idx + 1;
|
|
@@ -521,7 +521,7 @@ export function renderHtmlReport(input) {
|
|
|
521
521
|
<div style="display:flex;align-items:center;gap:6px;margin-bottom:4px">
|
|
522
522
|
<span style="font-size:.75em;font-weight:700;opacity:.5;min-width:22px">#${num}</span>
|
|
523
523
|
<code style="display:inline-block;background:#fff;color:#1e293b;font-size:.8em;font-weight:600;padding:1px 7px;border-radius:4px;letter-spacing:.01em">${esc(branch.name)}</code>
|
|
524
|
-
${branch.isCurrent ? `<span style="font-size:.
|
|
524
|
+
${branch.isCurrent ? `<span style="font-size:.74em;background:#fff;color:#16a34a;font-weight:700;padding:1px 6px;border-radius:4px;border:1px solid #bbf7d0">← rama actual</span>` : ""}
|
|
525
525
|
</div>
|
|
526
526
|
${commitsHtml}
|
|
527
527
|
</div>`;
|
package/package.json
CHANGED