hillclimb 0.8.7 → 0.8.8
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/main.js +95 -27
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -14402,6 +14402,35 @@ import fs14 from "fs";
|
|
|
14402
14402
|
import os7 from "os";
|
|
14403
14403
|
import path14 from "path";
|
|
14404
14404
|
import { createGzip } from "zlib";
|
|
14405
|
+
|
|
14406
|
+
// src/git-traces/timing.ts
|
|
14407
|
+
import { performance } from "perf_hooks";
|
|
14408
|
+
function startCaptureStage(stage, context) {
|
|
14409
|
+
appendLog(
|
|
14410
|
+
"info",
|
|
14411
|
+
`git-traces: capture timing (${context}, stage=${stage}, status=started)`
|
|
14412
|
+
);
|
|
14413
|
+
const started = performance.now();
|
|
14414
|
+
return (status) => {
|
|
14415
|
+
appendLog(
|
|
14416
|
+
"info",
|
|
14417
|
+
`git-traces: capture timing (${context}, stage=${stage}, status=${status}, elapsedMs=${Math.round(performance.now() - started)})`
|
|
14418
|
+
);
|
|
14419
|
+
};
|
|
14420
|
+
}
|
|
14421
|
+
function timeCaptureStage(repoRoot, stage, run) {
|
|
14422
|
+
const finish = startCaptureStage(stage, `repo=${repoRoot}`);
|
|
14423
|
+
let status = "failed";
|
|
14424
|
+
try {
|
|
14425
|
+
const result = run();
|
|
14426
|
+
status = "ok";
|
|
14427
|
+
return result;
|
|
14428
|
+
} finally {
|
|
14429
|
+
finish(status);
|
|
14430
|
+
}
|
|
14431
|
+
}
|
|
14432
|
+
|
|
14433
|
+
// src/git-traces/git-ops.ts
|
|
14405
14434
|
var DEFAULT_GIT_COMMAND_TIMEOUT_MS = 12e4;
|
|
14406
14435
|
var FULL_TREE_SCAN_TIMEOUT_MS = 3e5;
|
|
14407
14436
|
function resolveGitCommandTimeoutMs() {
|
|
@@ -14724,7 +14753,11 @@ function isGitRepo(dir) {
|
|
|
14724
14753
|
}
|
|
14725
14754
|
function captureWorkingCommitSha(repoRoot) {
|
|
14726
14755
|
try {
|
|
14727
|
-
const sha =
|
|
14756
|
+
const sha = timeCaptureStage(
|
|
14757
|
+
repoRoot,
|
|
14758
|
+
"stash-create",
|
|
14759
|
+
() => git(repoRoot, ["stash", "create"])
|
|
14760
|
+
);
|
|
14728
14761
|
if (sha) return sha;
|
|
14729
14762
|
} catch (err) {
|
|
14730
14763
|
if (isGitTimeoutError(err)) throw err;
|
|
@@ -14971,33 +15004,39 @@ function removePathsFromIndex(repoRoot, env, paths) {
|
|
|
14971
15004
|
});
|
|
14972
15005
|
}
|
|
14973
15006
|
function filterOmittedFilesFromTree(repoRoot, treeSha, options = {}) {
|
|
14974
|
-
const omittedFiles =
|
|
15007
|
+
const omittedFiles = timeCaptureStage(
|
|
14975
15008
|
repoRoot,
|
|
14976
|
-
|
|
14977
|
-
|
|
14978
|
-
|
|
15009
|
+
"omission-scan",
|
|
15010
|
+
() => listOmittedTreeFiles(
|
|
15011
|
+
repoRoot,
|
|
15012
|
+
treeSha,
|
|
15013
|
+
options.limits ?? DEFAULT_SNAPSHOT_LIMITS,
|
|
15014
|
+
options.previousScan
|
|
15015
|
+
)
|
|
14979
15016
|
);
|
|
14980
15017
|
options.omittedFiles?.push(...omittedFiles);
|
|
14981
|
-
|
|
14982
|
-
|
|
14983
|
-
|
|
14984
|
-
|
|
14985
|
-
|
|
14986
|
-
const env = { ...process.env, GIT_INDEX_FILE: tmpIndex };
|
|
14987
|
-
try {
|
|
14988
|
-
gitWithEnv(repoRoot, ["read-tree", treeSha], env);
|
|
14989
|
-
removePathsFromIndex(
|
|
14990
|
-
repoRoot,
|
|
14991
|
-
env,
|
|
14992
|
-
omittedFiles.map((file) => file.path)
|
|
15018
|
+
return timeCaptureStage(repoRoot, "tracked-tree-filter", () => {
|
|
15019
|
+
if (omittedFiles.length === 0) return treeSha;
|
|
15020
|
+
const tmpIndex = path14.join(
|
|
15021
|
+
os7.tmpdir(),
|
|
15022
|
+
`hillclimb-filter-${Date.now()}-${process.pid}`
|
|
14993
15023
|
);
|
|
14994
|
-
|
|
14995
|
-
} finally {
|
|
15024
|
+
const env = { ...process.env, GIT_INDEX_FILE: tmpIndex };
|
|
14996
15025
|
try {
|
|
14997
|
-
|
|
14998
|
-
|
|
15026
|
+
gitWithEnv(repoRoot, ["read-tree", treeSha], env);
|
|
15027
|
+
removePathsFromIndex(
|
|
15028
|
+
repoRoot,
|
|
15029
|
+
env,
|
|
15030
|
+
omittedFiles.map((file) => file.path)
|
|
15031
|
+
);
|
|
15032
|
+
return gitWithEnv(repoRoot, ["write-tree"], env);
|
|
15033
|
+
} finally {
|
|
15034
|
+
try {
|
|
15035
|
+
fs14.unlinkSync(tmpIndex);
|
|
15036
|
+
} catch {
|
|
15037
|
+
}
|
|
14999
15038
|
}
|
|
15000
|
-
}
|
|
15039
|
+
});
|
|
15001
15040
|
}
|
|
15002
15041
|
function buildUntrackedTree(repoRoot, options = {}) {
|
|
15003
15042
|
const limits = options.limits ?? DEFAULT_SNAPSHOT_LIMITS;
|
|
@@ -15056,7 +15095,11 @@ function buildUntrackedTree(repoRoot, options = {}) {
|
|
|
15056
15095
|
function buildSnapshotTree(repoRoot, stashSha, options = {}) {
|
|
15057
15096
|
const omittedFiles = options.omittedFiles ?? [];
|
|
15058
15097
|
const limits = options.limits ?? DEFAULT_SNAPSHOT_LIMITS;
|
|
15059
|
-
const trackedTree =
|
|
15098
|
+
const trackedTree = timeCaptureStage(
|
|
15099
|
+
repoRoot,
|
|
15100
|
+
"tracked-tree-resolve",
|
|
15101
|
+
() => git(repoRoot, ["rev-parse", `${stashSha}^{tree}`])
|
|
15102
|
+
);
|
|
15060
15103
|
const trackedOmitted = [];
|
|
15061
15104
|
const filteredTrackedTree = filterOmittedFilesFromTree(
|
|
15062
15105
|
repoRoot,
|
|
@@ -15068,12 +15111,16 @@ function buildSnapshotTree(repoRoot, stashSha, options = {}) {
|
|
|
15068
15111
|
}
|
|
15069
15112
|
);
|
|
15070
15113
|
omittedFiles.push(...trackedOmitted);
|
|
15071
|
-
const untrackedTree =
|
|
15114
|
+
const untrackedTree = timeCaptureStage(
|
|
15115
|
+
repoRoot,
|
|
15116
|
+
"untracked-capture",
|
|
15117
|
+
() => buildUntrackedTree(repoRoot, { omittedFiles, limits })
|
|
15118
|
+
);
|
|
15072
15119
|
if (options.log !== false) logOmittedSnapshotSummary(omittedFiles);
|
|
15073
|
-
const snapshotTree =
|
|
15120
|
+
const snapshotTree = timeCaptureStage(
|
|
15074
15121
|
repoRoot,
|
|
15075
|
-
|
|
15076
|
-
untrackedTree
|
|
15122
|
+
"tree-assembly",
|
|
15123
|
+
() => mergeSnapshotTrees(repoRoot, filteredTrackedTree, untrackedTree)
|
|
15077
15124
|
);
|
|
15078
15125
|
options.scanOut?.push({
|
|
15079
15126
|
trackedTreeSha: trackedTree,
|
|
@@ -15709,6 +15756,27 @@ async function deleteLegacySessionState(repoRoot, tool, sessionId) {
|
|
|
15709
15756
|
if (legacy?.sessionId === sessionId) await deleteStateFile(legacyFile);
|
|
15710
15757
|
}
|
|
15711
15758
|
async function acquireLock3(repoRoot, tool, sessionId, retries, delayMs, options = {}) {
|
|
15759
|
+
const finish = startCaptureStage(
|
|
15760
|
+
"lock-wait",
|
|
15761
|
+
`repo=${repoRoot}, tool=${tool}, session=${sessionId || "<legacy>"}`
|
|
15762
|
+
);
|
|
15763
|
+
let status = "failed";
|
|
15764
|
+
try {
|
|
15765
|
+
const result = await acquireLockWithoutTiming(
|
|
15766
|
+
repoRoot,
|
|
15767
|
+
tool,
|
|
15768
|
+
sessionId,
|
|
15769
|
+
retries,
|
|
15770
|
+
delayMs,
|
|
15771
|
+
options
|
|
15772
|
+
);
|
|
15773
|
+
status = "ok";
|
|
15774
|
+
return result;
|
|
15775
|
+
} finally {
|
|
15776
|
+
finish(status);
|
|
15777
|
+
}
|
|
15778
|
+
}
|
|
15779
|
+
async function acquireLockWithoutTiming(repoRoot, tool, sessionId, retries, delayMs, options = {}) {
|
|
15712
15780
|
const lockPath = lockFileForRepo(repoRoot, tool, sessionId);
|
|
15713
15781
|
await fs15.promises.mkdir(stateDir3(), { recursive: true, mode: 448 });
|
|
15714
15782
|
const bounded = retries !== void 0 || delayMs !== void 0;
|