Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 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 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 | 3x 3x 3x 3x 3x 3x 3x 16x 16x 16x 16x 16x 16x 16x 8x 8x 8x 1x 1x 1x 7x 7x 7x 7x 8x 8x 2x 2x 2x 5x 5x 5x 5x 8x 1x 1x 4x 4x 4x 4x 4x 4x 4x 8x 1x 1x 3x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 2x 8x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 16x 16x 3x 16x 16x 9x 9x 9x 1x 1x 1x 8x 8x 8x 8x 8x 9x 1x 1x 7x 7x 7x 7x 7x 9x 1x 1x 1x 1x 9x 9x 9x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 9x 9x 9x 9x 9x 9x 9x 9x 9x 1x 1x 1x 16x 16x 3x 3x 3x 3x 3x | const {
getWorkspaceRoot,
getCriticalIssueCount,
logIssues,
showWorkspaceRequiredError,
} = require("./shared");
function createCompareBranchesHandler({
vscodeApi,
logger,
codeReviewPanel,
prReviewService,
}) {
return async () => {
try {
const workspaceRoot = getWorkspaceRoot(vscodeApi);
if (!workspaceRoot) {
showWorkspaceRequiredError(vscodeApi);
return;
}
const branchesResult = await Promise.resolve(
prReviewService.getBranches(workspaceRoot),
);
const branches = Array.isArray(branchesResult) ? branchesResult : [];
if (branches.length === 0) {
vscodeApi.window.showErrorMessage("No se encontraron branches");
return;
}
const baseRef = await vscodeApi.window.showQuickPick(branches, {
placeHolder: "Selecciona branch base (ej: main, develop)",
});
if (!baseRef) {
return;
}
const targetRef = await vscodeApi.window.showQuickPick(
["HEAD (current)", ...branches.filter((branch) => branch !== baseRef)],
{
placeHolder: "Selecciona branch target (ej: feature/new-feature)",
},
);
if (!targetRef) {
return;
}
const target = targetRef === "HEAD (current)" ? "HEAD" : targetRef;
logger.info(`Comparando: ${target} vs ${baseRef}...`);
vscodeApi.window.showInformationMessage(
"Comparando branches con Copilot...",
);
codeReviewPanel.showReviewStarted();
const result = await prReviewService.reviewBranchComparison(
workspaceRoot,
baseRef,
target,
);
if (result.issues.length === 0) {
vscodeApi.window.showInformationMessage(result.message);
return;
}
const criticalCount = getCriticalIssueCount(result);
vscodeApi.window.showInformationMessage(
`${result.issues.length} issue(s) - ${criticalCount} critico(s)`,
);
logIssues(logger, result);
} catch (error) {
vscodeApi.window.showErrorMessage(`Error: ${error.message}`);
logger.error(`Error en compareBranches: ${error.message}`);
}
};
}
function createShowChangeStatsHandler({ vscodeApi, logger, prReviewService }) {
return async () => {
try {
const workspaceRoot = getWorkspaceRoot(vscodeApi);
if (!workspaceRoot) {
showWorkspaceRequiredError(vscodeApi);
return;
}
const staged = await vscodeApi.window.showQuickPick(
["Unstaged changes", "Staged changes"],
{ placeHolder: "Que cambios quieres analizar?" },
);
if (!staged) {
return;
}
const isStaged = staged === "Staged changes";
const statsResult = await Promise.resolve(
prReviewService.getChangeStats(workspaceRoot, isStaged),
);
const stats = statsResult || {
filesChanged: 0,
additions: 0,
deletions: 0,
files: [],
};
if (stats.filesChanged === 0) {
vscodeApi.window.showInformationMessage(
`No hay cambios ${isStaged ? "staged" : "unstaged"}`,
);
return;
}
const message = `${stats.filesChanged} archivo(s) | +${stats.additions} -${stats.deletions}`;
vscodeApi.window.showInformationMessage(message);
logger.info(
`\nESTADISTICAS DE CAMBIOS (${isStaged ? "STAGED" : "UNSTAGED"}):`,
);
logger.info(` Archivos modificados: ${stats.filesChanged}`);
logger.info(` Lineas agregadas: +${stats.additions}`);
logger.info(` Lineas eliminadas: -${stats.deletions}`);
logger.info("\n Archivos:");
const files = Array.isArray(stats.files) ? stats.files : [];
files.forEach((file) => logger.info(` - ${file}`));
} catch (error) {
vscodeApi.window.showErrorMessage(`Error: ${error.message}`);
logger.error(`Error en showChangeStats: ${error.message}`);
}
};
}
module.exports = {
createCompareBranchesHandler,
createShowChangeStatsHandler,
};
|