pull-request-split-advisor 3.2.9 → 3.2.10

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 CHANGED
@@ -419,13 +419,30 @@ async function main() {
419
419
  }
420
420
  // ─── Pipeline de análisis ────────────────────────────────────────────────
421
421
  ui.spinner.start("Analizando cambios del working tree...");
422
- const changedFiles = gatherChangedFiles(config, baseBranch);
423
- if (!changedFiles.length) {
422
+ const allChangedFiles = gatherChangedFiles(config, baseBranch);
423
+ if (!allChangedFiles.length) {
424
424
  ui.spinner.stop();
425
425
  ui.warn("No hay cambios respecto a la rama base.");
426
426
  closeReadlineInterface();
427
427
  return;
428
428
  }
429
+ // ─── Computar origen de cada archivo en el árbol git ─────────────────────
430
+ // Se calcula ANTES del pipeline para filtrar el análisis a solo cambios
431
+ // del working tree (WIP: sin commitear o nuevos sin rastrear).
432
+ // Archivos ya commiteados (local-commit / pushed) quedan excluidos del
433
+ // plan de PRs, igual que hace el subcomando 'score'.
434
+ resetTrackedFilesCache();
435
+ const origins = computeFileOrigins(allChangedFiles, baseBranch, currentBranch, remote);
436
+ const changedFiles = allChangedFiles.filter((f) => {
437
+ const o = origins.get(f) ?? "working-tree";
438
+ return o === "working-tree" || o === "untracked";
439
+ });
440
+ if (changedFiles.length === 0) {
441
+ ui.spinner.stop();
442
+ ui.info("No hay cambios en el working tree. Solo existen commits locales o publicados.");
443
+ closeReadlineInterface();
444
+ return;
445
+ }
429
446
  const fileStats = getFileStats(changedFiles, baseBranch);
430
447
  const deps = buildDependencyEdges(changedFiles);
431
448
  const blocks = buildBlocks(fileStats, config, deps);
@@ -437,13 +454,6 @@ async function main() {
437
454
  const plans = findBestPlan(blocks, currentBranch, config, deps);
438
455
  config.testCoveragePercent = computeTestCoveragePercent(fileStats);
439
456
  ui.spinner.stop("Analisis completado.");
440
- // ─── Computar origen de cada archivo en el árbol git ─────────────────────
441
- // Diferencia entre: ya publicado (REMOTO), commiteado local (LOCAL),
442
- // cambio sin commitear (WIP) y archivo nuevo sin rastrear (NUEVO).
443
- // Resetear la caché de tracked files para que computeFileOrigins use
444
- // un Set fresco (evita stale data si el index cambió durante el análisis).
445
- resetTrackedFilesCache();
446
- const origins = computeFileOrigins(changedFiles, baseBranch, currentBranch, remote);
447
457
  for (const stat of fileStats) {
448
458
  stat.origin = origins.get(stat.path);
449
459
  }
@@ -462,7 +472,8 @@ async function main() {
462
472
  printBlocks(blocks);
463
473
  printPlans(plans, baseBranch, currentBranch, config);
464
474
  // ─── Exportar reporte HTML ───────────────────────────────────────────────
465
- const wipFileStats = fileStats.filter((f) => !f.origin || f.origin === "working-tree" || f.origin === "untracked");
475
+ // Todos los fileStats ya son WIP (filtrado antes del pipeline).
476
+ const wipFileStats = fileStats;
466
477
  const reportInput = { currentBranch, baseBranch, config, fileStats, wipFileStats, deps, blocks, plans, cascadeWarning };
467
478
  const htmlFile = "pr-split-report.html";
468
479
  writeHtmlReport(htmlFile, reportInput);
package/dist/git/git.js CHANGED
@@ -294,17 +294,19 @@ function discoverSortedSiblings(currentBranch, baseBranch, familyPrefix) {
294
294
  !/backup/i.test(name));
295
295
  if (candidates.length === 0)
296
296
  return [];
297
- const withAhead = candidates.filter(({ ref }) => {
298
- const count = shSafe(`git rev-list ${q(baseBranch)}..${q(ref)} --count`);
299
- return (parseInt(count, 10) || 0) > 0;
300
- });
297
+ const withAhead = candidates
298
+ .map(({ name, ref }) => ({
299
+ name,
300
+ ref,
301
+ count: parseInt(shSafe(`git rev-list ${q(baseBranch)}..${q(ref)} --count`), 10) || 0,
302
+ }))
303
+ .filter(({ count }) => count > 0);
301
304
  if (withAhead.length === 0)
302
305
  return [];
303
- return withAhead.sort((a, b) => {
304
- const dateA = shSafe(`git log -1 --format=%ct ${q(a.ref)}`);
305
- const dateB = shSafe(`git log -1 --format=%ct ${q(b.ref)}`);
306
- return (parseInt(dateB, 10) || 0) - (parseInt(dateA, 10) || 0);
307
- });
306
+ // Ordenar por de commits DESC: más commits = más al final de la cadena de cascada.
307
+ // findCascadeParent toma sorted[0] (más commits = rama más reciente = padre correcto).
308
+ // findCascadeSiblings invierte el array → orden ASC = menos commits (#1) primero.
309
+ return withAhead.sort((a, b) => b.count - a.count);
308
310
  }
309
311
  /**
310
312
  * Busca la rama hermana más reciente de la misma "familia" con commits adelantados
@@ -518,7 +518,11 @@ export function renderHtmlReport(input) {
518
518
  `<span style="opacity:.9">${esc(c.subject)}</span></li>`).join("")}</ul>`
519
519
  : `<div style="font-size:.8em;opacity:.5;margin-top:2px">Sin commits</div>`;
520
520
  return `<div style="margin:6px 0;padding:8px 10px;background:rgba(0,0,0,.15);border-radius:5px;border-left:3px solid ${color}">
521
- <div style="font-weight:600;font-size:.88em;color:${color}"><span style="opacity:.55;margin-right:6px">#${num}</span>${esc(branch.name)}${branch.isCurrent ? " <span style=\"font-size:.8em;opacity:.7\">← rama actual</span>" : ""}</div>
521
+ <div style="display:flex;align-items:center;gap:6px;margin-bottom:4px">
522
+ <span style="font-size:.75em;font-weight:700;opacity:.5;min-width:22px">#${num}</span>
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:.75em;color:#e2e8f0;opacity:.7">← rama actual</span>` : ""}
525
+ </div>
522
526
  ${commitsHtml}
523
527
  </div>`;
524
528
  }).join("");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pull-request-split-advisor",
3
- "version": "3.2.9",
3
+ "version": "3.2.10",
4
4
  "description": "CLI that analyses your Git working tree and suggests how to split changes into smaller, reviewable pull requests and commits.",
5
5
  "keywords": [
6
6
  "git",