pull-request-split-advisor 3.2.4 → 3.2.6
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 +2 -7
- package/dist/git/git.js +38 -16
- package/dist/output/report.js +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -393,14 +393,9 @@ async function main() {
|
|
|
393
393
|
` git checkout ${branchFrom}`,
|
|
394
394
|
` git checkout -b ${suggestedBranch}`,
|
|
395
395
|
"",
|
|
396
|
-
"
|
|
397
|
-
"La opción --apply
|
|
396
|
+
"El análisis continúa de forma informativa.",
|
|
397
|
+
"La opción --apply está deshabilitada en esta ejecución."
|
|
398
398
|
], "red");
|
|
399
|
-
const continueAnyway = await ui.confirm("¿Deseas continuar de todas formas (solo análisis, sin aplicar)?");
|
|
400
|
-
if (!continueAnyway) {
|
|
401
|
-
closeReadlineInterface();
|
|
402
|
-
return;
|
|
403
|
-
}
|
|
404
399
|
}
|
|
405
400
|
// ─── Pipeline de análisis ────────────────────────────────────────────────
|
|
406
401
|
ui.spinner.start("Analizando cambios del working tree...");
|
package/dist/git/git.js
CHANGED
|
@@ -243,33 +243,55 @@ export function findCascadeParent(currentBranch, baseBranch) {
|
|
|
243
243
|
if (!familyMatch)
|
|
244
244
|
return null;
|
|
245
245
|
const familyPrefix = `${familyMatch[1]}/${familyMatch[2].toUpperCase()}`;
|
|
246
|
-
//
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
246
|
+
// Construir lista de ramas locales Y remotas para no perder ramas hermanas
|
|
247
|
+
// que existen en el remoto pero aún no han sido descargadas localmente.
|
|
248
|
+
// Para cada entrada guardamos { name, ref }:
|
|
249
|
+
// - name: nombre de la rama sin prefijo de remoto (para mostrar al usuario y para checkout)
|
|
250
|
+
// - ref: ref resolvible por git (local: igual al name; remota: "origin/feature/…")
|
|
251
|
+
const branches = [];
|
|
252
|
+
// Ramas locales
|
|
253
|
+
const localRaw = shSafe("git branch --format=%(refname:short)");
|
|
254
|
+
for (const b of localRaw.split("\n").map((s) => s.trim()).filter(Boolean)) {
|
|
255
|
+
branches.push({ name: b, ref: b });
|
|
256
|
+
}
|
|
257
|
+
// Ramas remotas (ej. "origin/feature/FASTY-0001-xyz")
|
|
258
|
+
// Se usa el nombre sin el prefijo del remoto (primer segmento hasta "/").
|
|
259
|
+
// Si ya existe la rama localmente, se omite (la ref local tiene precedencia).
|
|
260
|
+
const remoteRaw = shSafe("git branch -r --format=%(refname:short)");
|
|
261
|
+
for (const b of remoteRaw.split("\n").map((s) => s.trim()).filter(Boolean)) {
|
|
262
|
+
const slash = b.indexOf("/");
|
|
263
|
+
if (slash < 0)
|
|
264
|
+
continue;
|
|
265
|
+
const name = b.slice(slash + 1); // "origin/feature/…" → "feature/…"
|
|
266
|
+
if (!name || name.startsWith("HEAD"))
|
|
267
|
+
continue;
|
|
268
|
+
if (!branches.some((x) => x.name === name)) {
|
|
269
|
+
branches.push({ name, ref: b }); // ref = "origin/feature/…" (resolvible sin checkout)
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
const candidates = branches.filter(({ name }) => name !== currentBranch &&
|
|
273
|
+
name.toUpperCase().startsWith(familyPrefix.toUpperCase()));
|
|
256
274
|
if (candidates.length === 0)
|
|
257
275
|
return null;
|
|
258
276
|
// De los candidatos, quedarnos con los que tengan commits adelantados
|
|
259
|
-
// respecto a la base y ordenarlos por committerdate descendente
|
|
260
|
-
|
|
261
|
-
|
|
277
|
+
// respecto a la base y ordenarlos por committerdate descendente.
|
|
278
|
+
// Si la rama solo existe en el remoto, la ref "origin/feature/…" es
|
|
279
|
+
// resolvible directamente por git sin necesidad de checkout local.
|
|
280
|
+
const withAhead = candidates.filter(({ ref }) => {
|
|
281
|
+
const count = shSafe(`git rev-list ${q(baseBranch)}..${q(ref)} --count`);
|
|
262
282
|
return (parseInt(count, 10) || 0) > 0;
|
|
263
283
|
});
|
|
264
284
|
if (withAhead.length === 0)
|
|
265
285
|
return null;
|
|
266
286
|
// El más reciente es el que tiene el commit más nuevo
|
|
267
287
|
const sorted = withAhead.sort((a, b) => {
|
|
268
|
-
const dateA = shSafe(`git log -1 --format=%ct ${q(a)}`);
|
|
269
|
-
const dateB = shSafe(`git log -1 --format=%ct ${q(b)}`);
|
|
288
|
+
const dateA = shSafe(`git log -1 --format=%ct ${q(a.ref)}`);
|
|
289
|
+
const dateB = shSafe(`git log -1 --format=%ct ${q(b.ref)}`);
|
|
270
290
|
return (parseInt(dateB, 10) || 0) - (parseInt(dateA, 10) || 0);
|
|
271
291
|
});
|
|
272
|
-
|
|
292
|
+
// Retornar el nombre sin prefijo de remoto para que el usuario pueda usar
|
|
293
|
+
// "git checkout <name>" y git resuelva automáticamente la ref de tracking.
|
|
294
|
+
return sorted[0]?.name ?? null;
|
|
273
295
|
}
|
|
274
296
|
/**
|
|
275
297
|
* Hace push de una rama local al remoto indicado.
|
package/dist/output/report.js
CHANGED
|
@@ -519,7 +519,7 @@ export function renderHtmlReport(input) {
|
|
|
519
519
|
<p>${parentNote}</p>
|
|
520
520
|
<p><strong>Comandos recomendados:</strong></p>
|
|
521
521
|
<pre style="background:rgba(0,0,0,.25);padding:10px 14px;border-radius:6px;font-size:.85em;margin:8px 0 0"># Crear la siguiente rama de la cascada\ngit checkout ${esc(cw.branchFrom)}\ngit checkout -b ${esc(cw.suggestedBranch)}</pre>
|
|
522
|
-
<p class="disclaimer-footer" style="margin-top:8px">El apply
|
|
522
|
+
<p class="disclaimer-footer" style="margin-top:8px">Este reporte es informativo. El apply quedó deshabilitado en esta ejecución para preservar la integridad del plan en cascada.</p>
|
|
523
523
|
</div>
|
|
524
524
|
</section>`;
|
|
525
525
|
})() : ""}
|
package/package.json
CHANGED