@aisdlc/core 2.2.2 → 2.2.3
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/index.cjs +59 -19
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +9 -1
- package/dist/index.d.ts +9 -1
- package/dist/index.js +58 -20
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -9824,10 +9824,39 @@ function computeReworkRatios(totalTime, totalTokens, totalCost, reworkTime, rewo
|
|
|
9824
9824
|
costPercent: totalCost > 0 ? Math.round(reworkCost / totalCost * 1e4) / 100 : 0
|
|
9825
9825
|
};
|
|
9826
9826
|
}
|
|
9827
|
-
function
|
|
9827
|
+
function resolveReleaseBaseBranch(release, explicitBase, options = {}) {
|
|
9828
9828
|
const cwd = options.cwd || process.cwd();
|
|
9829
|
+
if (explicitBase && explicitBase !== release) {
|
|
9830
|
+
return explicitBase;
|
|
9831
|
+
}
|
|
9832
|
+
if (release !== "main" && release !== "master") {
|
|
9833
|
+
return "main";
|
|
9834
|
+
}
|
|
9835
|
+
try {
|
|
9836
|
+
const lastTag = child_process.execFileSync("git", ["describe", "--tags", "--abbrev=0", `${release}^`], {
|
|
9837
|
+
cwd,
|
|
9838
|
+
encoding: "utf-8",
|
|
9839
|
+
stdio: ["pipe", "pipe", "pipe"]
|
|
9840
|
+
}).trim();
|
|
9841
|
+
if (lastTag) return lastTag;
|
|
9842
|
+
} catch {
|
|
9843
|
+
}
|
|
9844
|
+
try {
|
|
9845
|
+
const rootSha = child_process.execFileSync("git", ["rev-list", "--max-parents=0", release], {
|
|
9846
|
+
cwd,
|
|
9847
|
+
encoding: "utf-8",
|
|
9848
|
+
stdio: ["pipe", "pipe", "pipe"]
|
|
9849
|
+
}).trim().split("\n")[0];
|
|
9850
|
+
if (rootSha) return rootSha;
|
|
9851
|
+
} catch {
|
|
9852
|
+
}
|
|
9853
|
+
return release;
|
|
9854
|
+
}
|
|
9855
|
+
function aggregateReleaseKpis(releaseBranch, baseBranch, options = {}) {
|
|
9856
|
+
const cwd = options.cwd || process.cwd();
|
|
9857
|
+
const effectiveBase = resolveReleaseBaseBranch(releaseBranch, baseBranch, { cwd });
|
|
9829
9858
|
const resolvedRelease = resolveGitRef(cwd, releaseBranch);
|
|
9830
|
-
const resolvedBase = resolveGitRef(cwd,
|
|
9859
|
+
const resolvedBase = resolveGitRef(cwd, effectiveBase);
|
|
9831
9860
|
const records = extractCommitKpisFromRange(resolvedBase, resolvedRelease, options);
|
|
9832
9861
|
const statsMap = {};
|
|
9833
9862
|
const bugList = [];
|
|
@@ -12400,33 +12429,42 @@ function resolveActiveBranch(rootDir) {
|
|
|
12400
12429
|
return "HEAD";
|
|
12401
12430
|
}
|
|
12402
12431
|
}
|
|
12403
|
-
function
|
|
12432
|
+
function resolveRootCommit(rootDir, targetRef) {
|
|
12404
12433
|
try {
|
|
12405
|
-
|
|
12406
|
-
|
|
12407
|
-
|
|
12408
|
-
|
|
12409
|
-
|
|
12410
|
-
|
|
12411
|
-
|
|
12412
|
-
|
|
12413
|
-
|
|
12414
|
-
|
|
12434
|
+
return child_process.execFileSync("git", ["rev-list", "--max-parents=0", targetRef], {
|
|
12435
|
+
cwd: rootDir,
|
|
12436
|
+
encoding: "utf-8",
|
|
12437
|
+
stdio: ["pipe", "pipe", "pipe"]
|
|
12438
|
+
}).trim().split("\n")[0] || targetRef;
|
|
12439
|
+
} catch {
|
|
12440
|
+
return targetRef;
|
|
12441
|
+
}
|
|
12442
|
+
}
|
|
12443
|
+
function resolveDefaultBranchBase(rootDir, targetRef = "HEAD") {
|
|
12444
|
+
try {
|
|
12445
|
+
const rawCount = child_process.execFileSync("git", ["rev-list", "--count", "--first-parent", targetRef], {
|
|
12446
|
+
cwd: rootDir,
|
|
12447
|
+
encoding: "utf-8",
|
|
12448
|
+
stdio: ["pipe", "pipe", "pipe"]
|
|
12449
|
+
}).trim();
|
|
12450
|
+
const firstParentCount = parseInt(rawCount, 10);
|
|
12451
|
+
if (firstParentCount > 20) {
|
|
12452
|
+
const candidateRef = `${targetRef}~20`;
|
|
12453
|
+
child_process.execFileSync("git", ["rev-parse", "--verify", "--quiet", candidateRef], {
|
|
12415
12454
|
cwd: rootDir,
|
|
12416
|
-
encoding: "utf-8",
|
|
12417
12455
|
stdio: ["pipe", "pipe", "pipe"]
|
|
12418
|
-
})
|
|
12456
|
+
});
|
|
12457
|
+
return candidateRef;
|
|
12419
12458
|
}
|
|
12420
|
-
return "HEAD~20";
|
|
12421
12459
|
} catch {
|
|
12422
|
-
return "HEAD~1";
|
|
12423
12460
|
}
|
|
12461
|
+
return resolveRootCommit(rootDir, targetRef);
|
|
12424
12462
|
}
|
|
12425
12463
|
function resolveActivePrKpi(rootDir, activeBranch) {
|
|
12426
12464
|
try {
|
|
12427
12465
|
const isDefaultBranch = activeBranch === "main" || activeBranch === "master";
|
|
12428
12466
|
if (isDefaultBranch) {
|
|
12429
|
-
const base = resolveDefaultBranchBase(rootDir);
|
|
12467
|
+
const base = resolveDefaultBranchBase(rootDir, "HEAD");
|
|
12430
12468
|
return aggregatePrKpis(base, "HEAD", { cwd: rootDir });
|
|
12431
12469
|
}
|
|
12432
12470
|
const prKpi = aggregatePrKpis("main", "HEAD", { cwd: rootDir });
|
|
@@ -12481,7 +12519,7 @@ function resolveCandidateBranches(rootDir, activeBranch, history) {
|
|
|
12481
12519
|
function fetchBranchKpi(rootDir, branch) {
|
|
12482
12520
|
try {
|
|
12483
12521
|
const isDefault = branch === "main" || branch === "master";
|
|
12484
|
-
const base = isDefault ? resolveDefaultBranchBase(rootDir) : "main";
|
|
12522
|
+
const base = isDefault ? resolveDefaultBranchBase(rootDir, branch) : "main";
|
|
12485
12523
|
const kpi = aggregatePrKpis(base, branch, { cwd: rootDir });
|
|
12486
12524
|
return kpi && kpi.totalCommits > 0 ? kpi : null;
|
|
12487
12525
|
} catch {
|
|
@@ -16102,9 +16140,11 @@ exports.resolveAgentTargets = resolveAgentTargets;
|
|
|
16102
16140
|
exports.resolveBranchHierarchy = resolveBranchHierarchy;
|
|
16103
16141
|
exports.resolveCiEnvironment = resolveCiEnvironment;
|
|
16104
16142
|
exports.resolveCytoscapePath = resolveCytoscapePath;
|
|
16143
|
+
exports.resolveDefaultBranchBase = resolveDefaultBranchBase;
|
|
16105
16144
|
exports.resolveFeatureFilePath = resolveFeatureFilePath;
|
|
16106
16145
|
exports.resolveGitRef = resolveGitRef;
|
|
16107
16146
|
exports.resolveLicenseFromFile = resolveLicenseFromFile;
|
|
16147
|
+
exports.resolveReleaseBaseBranch = resolveReleaseBaseBranch;
|
|
16108
16148
|
exports.resolveSastCwe = resolveSastCwe;
|
|
16109
16149
|
exports.resolveSastOwasp = resolveSastOwasp;
|
|
16110
16150
|
exports.resolveSchemaForArtifact = resolveSchemaForArtifact;
|