repomind 0.9.1 → 0.9.2
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.js +44 -22
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -77070,9 +77070,20 @@ function parseDiffStats(diff2) {
|
|
|
77070
77070
|
if (currentPath !== null) {
|
|
77071
77071
|
files.push({ path: currentPath, additions, deletions });
|
|
77072
77072
|
}
|
|
77073
|
-
const
|
|
77074
|
-
const
|
|
77075
|
-
|
|
77073
|
+
const byPath = /* @__PURE__ */ new Map();
|
|
77074
|
+
for (const f of files) {
|
|
77075
|
+
const existing = byPath.get(f.path);
|
|
77076
|
+
if (existing) {
|
|
77077
|
+
existing.additions += f.additions;
|
|
77078
|
+
existing.deletions += f.deletions;
|
|
77079
|
+
} else {
|
|
77080
|
+
byPath.set(f.path, { ...f });
|
|
77081
|
+
}
|
|
77082
|
+
}
|
|
77083
|
+
const merged = [...byPath.values()];
|
|
77084
|
+
const totalAdditions = merged.reduce((s, f) => s + f.additions, 0);
|
|
77085
|
+
const totalDeletions = merged.reduce((s, f) => s + f.deletions, 0);
|
|
77086
|
+
return { files: merged, totalAdditions, totalDeletions };
|
|
77076
77087
|
}
|
|
77077
77088
|
function verifyCommitIntegrity(originalDiff, committedDiff) {
|
|
77078
77089
|
const original = parseDiffStats(originalDiff);
|
|
@@ -77117,16 +77128,21 @@ function verifyCommitIntegrity(originalDiff, committedDiff) {
|
|
|
77117
77128
|
}
|
|
77118
77129
|
return { match: true };
|
|
77119
77130
|
}
|
|
77120
|
-
async function captureCommittedDiff(
|
|
77121
|
-
return runGitAt(
|
|
77131
|
+
async function captureCommittedDiff(wtPath, commitCount, repoRoot) {
|
|
77132
|
+
return runGitAt(repoRoot, [
|
|
77133
|
+
"-C",
|
|
77134
|
+
wtPath,
|
|
77135
|
+
"diff",
|
|
77136
|
+
`HEAD~${commitCount}..HEAD`
|
|
77137
|
+
]);
|
|
77122
77138
|
}
|
|
77123
77139
|
|
|
77124
77140
|
// ../../packages/git/src/worktree.ts
|
|
77125
|
-
async function applyPatchInWorktree(wtPath, patch) {
|
|
77141
|
+
async function applyPatchInWorktree(wtPath, patch, repoRoot) {
|
|
77126
77142
|
const normalizedPatch = patch.endsWith("\n") ? patch : `${patch}
|
|
77127
77143
|
`;
|
|
77128
|
-
const proc = Bun.spawn(["git", "apply", "--index", "--3way"], {
|
|
77129
|
-
cwd:
|
|
77144
|
+
const proc = Bun.spawn(["git", "-C", wtPath, "apply", "--index", "--3way"], {
|
|
77145
|
+
cwd: repoRoot,
|
|
77130
77146
|
stdin: "pipe",
|
|
77131
77147
|
stdout: "pipe",
|
|
77132
77148
|
stderr: "pipe"
|
|
@@ -77167,6 +77183,8 @@ async function commitViaWorktree(repoRoot, groups, options) {
|
|
|
77167
77183
|
log4(`creating worktree at: ${wtPath}`);
|
|
77168
77184
|
await runGitAt(repoRoot, ["worktree", "add", "--detach", wtPath, "HEAD"]);
|
|
77169
77185
|
try {
|
|
77186
|
+
let actualCommitCount = 0;
|
|
77187
|
+
const appliedPatches = [];
|
|
77170
77188
|
for (let i = 0; i < groups.length; i++) {
|
|
77171
77189
|
const group = groups[i];
|
|
77172
77190
|
log4(
|
|
@@ -77180,17 +77198,21 @@ async function commitViaWorktree(repoRoot, groups, options) {
|
|
|
77180
77198
|
log4(
|
|
77181
77199
|
` applying patch ${j + 1}/${group.patches.length} (${group.patches[j].length} chars)`
|
|
77182
77200
|
);
|
|
77183
|
-
await applyPatchInWorktree(wtPath, group.patches[j]);
|
|
77201
|
+
await applyPatchInWorktree(wtPath, group.patches[j], repoRoot);
|
|
77202
|
+
appliedPatches.push(group.patches[j]);
|
|
77184
77203
|
}
|
|
77185
|
-
await runGitAt(
|
|
77204
|
+
await runGitAt(repoRoot, ["-C", wtPath, "commit", "-m", group.message]);
|
|
77205
|
+
actualCommitCount++;
|
|
77186
77206
|
log4(" committed");
|
|
77187
77207
|
}
|
|
77188
|
-
if (
|
|
77189
|
-
const
|
|
77190
|
-
const
|
|
77191
|
-
|
|
77192
|
-
|
|
77208
|
+
if (actualCommitCount > 0 && !options?.skipVerification) {
|
|
77209
|
+
const expectedDiff = appliedPatches.join("\n");
|
|
77210
|
+
const committedDiff = await captureCommittedDiff(
|
|
77211
|
+
wtPath,
|
|
77212
|
+
actualCommitCount,
|
|
77213
|
+
repoRoot
|
|
77193
77214
|
);
|
|
77215
|
+
const verification = verifyCommitIntegrity(expectedDiff, committedDiff);
|
|
77194
77216
|
log4(
|
|
77195
77217
|
`verification: match=${verification.match}${verification.details ? ` (${verification.details})` : ""}`
|
|
77196
77218
|
);
|
|
@@ -77200,7 +77222,7 @@ async function commitViaWorktree(repoRoot, groups, options) {
|
|
|
77200
77222
|
);
|
|
77201
77223
|
}
|
|
77202
77224
|
}
|
|
77203
|
-
const wtHead = (await runGitAt(
|
|
77225
|
+
const wtHead = (await runGitAt(repoRoot, ["-C", wtPath, "rev-parse", "HEAD"])).trim();
|
|
77204
77226
|
log4(`fast-forward: ${branchRef} -> ${wtHead}`);
|
|
77205
77227
|
await runGitAt(repoRoot, ["update-ref", branchRef, wtHead]);
|
|
77206
77228
|
await runGitAt(repoRoot, ["reset", "HEAD"]);
|
|
@@ -89510,7 +89532,11 @@ ${prefixed}`);
|
|
|
89510
89532
|
setPhase("verifying");
|
|
89511
89533
|
try {
|
|
89512
89534
|
const repoRoot = await deps.getRepoRoot();
|
|
89513
|
-
const committedDiff = await deps.captureCommittedDiff(
|
|
89535
|
+
const committedDiff = await deps.captureCommittedDiff(
|
|
89536
|
+
repoRoot,
|
|
89537
|
+
1,
|
|
89538
|
+
repoRoot
|
|
89539
|
+
);
|
|
89514
89540
|
const verification = deps.verifyCommitIntegrity(
|
|
89515
89541
|
rawDiff,
|
|
89516
89542
|
committedDiff
|
|
@@ -91440,12 +91466,8 @@ ${body}`;
|
|
|
91440
91466
|
const repoRoot = await deps.getRepoRoot();
|
|
91441
91467
|
log4(`repoRoot: ${repoRoot}`);
|
|
91442
91468
|
setPhase("verifying");
|
|
91443
|
-
const hasSkippedGroups = worktreeGroups.some(
|
|
91444
|
-
(g) => g.patches.length === 0
|
|
91445
|
-
);
|
|
91446
91469
|
await deps.commitViaWorktree(repoRoot, worktreeGroups, {
|
|
91447
|
-
originalDiff: originalRawDiff
|
|
91448
|
-
skipVerification: hasSkippedGroups
|
|
91470
|
+
originalDiff: originalRawDiff
|
|
91449
91471
|
});
|
|
91450
91472
|
log4("commitViaWorktree done (verified)");
|
|
91451
91473
|
let hashes = [];
|