@ricsam/r5d-worker 0.0.96 → 0.0.97
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/cjs/package.json
CHANGED
|
@@ -206,6 +206,14 @@ function indexMode(entry) {
|
|
|
206
206
|
function indexInfoRecord(mode, objectId, relativePath) {
|
|
207
207
|
return Buffer.concat([Buffer.from(`${mode} ${objectId} `), Buffer.from(relativePath), Buffer.from([0])]);
|
|
208
208
|
}
|
|
209
|
+
function basisGitlinks(workspacePath, basis) {
|
|
210
|
+
const listed = gitResult(workspacePath, ["ls-tree", "-r", "-z", `${basis.basisHead}:${basis.workspaceRelativePath}`]);
|
|
211
|
+
if (listed.exitCode !== 0) return [];
|
|
212
|
+
return nulRecords(listed.stdout).flatMap((record) => {
|
|
213
|
+
const match = /^160000 commit ([0-9a-f]{40,64})\t(.+)$/su.exec(record.toString());
|
|
214
|
+
return match ? [{ objectId: match[1], relativePath: match[2] }] : [];
|
|
215
|
+
});
|
|
216
|
+
}
|
|
209
217
|
function synthesizeMountTree(input) {
|
|
210
218
|
const sourceRoot = import_node_path.default.resolve(input.sourcePath);
|
|
211
219
|
const entries = (0, import_working_tree_mirror.inspectWorkingTree)(sourceRoot, input.sourceMode);
|
|
@@ -220,6 +228,15 @@ function synthesizeMountTree(input) {
|
|
|
220
228
|
const objectId = entry.kind === "file" ? hashRegularFile(input.workspacePath, sourcePath, entry) : hashSymlink(input.workspacePath, sourcePath, entry);
|
|
221
229
|
records.push(indexInfoRecord(indexMode(entry), objectId, relativePath));
|
|
222
230
|
}
|
|
231
|
+
if (input.gitlinkBasis && input.sourceMode === "git") {
|
|
232
|
+
for (const gitlink of basisGitlinks(input.workspacePath, input.gitlinkBasis)) {
|
|
233
|
+
const populatedPrefix = `${gitlink.relativePath}/`;
|
|
234
|
+
const populated = [...entries.keys()].some((relativePath) => relativePath.startsWith(populatedPrefix));
|
|
235
|
+
if (entries.get(gitlink.relativePath)?.kind === "directory" && !populated) {
|
|
236
|
+
records.push(indexInfoRecord("160000", gitlink.objectId, gitlink.relativePath));
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
}
|
|
223
240
|
if (records.length > 0) {
|
|
224
241
|
git(input.workspacePath, ["update-index", "-z", "--index-info"], "populate workspace projection index", {
|
|
225
242
|
environment,
|
|
@@ -284,7 +301,8 @@ function synthesizeOursCommit(input) {
|
|
|
284
301
|
const mountTree = synthesizeMountTree({
|
|
285
302
|
workspacePath: input.workspacePath,
|
|
286
303
|
sourcePath: input.mount.sourcePath,
|
|
287
|
-
sourceMode: input.mount.sourceMode
|
|
304
|
+
sourceMode: input.mount.sourceMode,
|
|
305
|
+
gitlinkBasis: { basisHead: input.basisHead, workspaceRelativePath: input.workspaceRelativePath }
|
|
288
306
|
});
|
|
289
307
|
const rootTree = graftMountTree({
|
|
290
308
|
workspacePath: input.workspacePath,
|
package/dist/mjs/package.json
CHANGED
|
@@ -170,6 +170,14 @@ function indexMode(entry) {
|
|
|
170
170
|
function indexInfoRecord(mode, objectId, relativePath) {
|
|
171
171
|
return Buffer.concat([Buffer.from(`${mode} ${objectId} `), Buffer.from(relativePath), Buffer.from([0])]);
|
|
172
172
|
}
|
|
173
|
+
function basisGitlinks(workspacePath, basis) {
|
|
174
|
+
const listed = gitResult(workspacePath, ["ls-tree", "-r", "-z", `${basis.basisHead}:${basis.workspaceRelativePath}`]);
|
|
175
|
+
if (listed.exitCode !== 0) return [];
|
|
176
|
+
return nulRecords(listed.stdout).flatMap((record) => {
|
|
177
|
+
const match = /^160000 commit ([0-9a-f]{40,64})\t(.+)$/su.exec(record.toString());
|
|
178
|
+
return match ? [{ objectId: match[1], relativePath: match[2] }] : [];
|
|
179
|
+
});
|
|
180
|
+
}
|
|
173
181
|
function synthesizeMountTree(input) {
|
|
174
182
|
const sourceRoot = path.resolve(input.sourcePath);
|
|
175
183
|
const entries = inspectWorkingTree(sourceRoot, input.sourceMode);
|
|
@@ -184,6 +192,15 @@ function synthesizeMountTree(input) {
|
|
|
184
192
|
const objectId = entry.kind === "file" ? hashRegularFile(input.workspacePath, sourcePath, entry) : hashSymlink(input.workspacePath, sourcePath, entry);
|
|
185
193
|
records.push(indexInfoRecord(indexMode(entry), objectId, relativePath));
|
|
186
194
|
}
|
|
195
|
+
if (input.gitlinkBasis && input.sourceMode === "git") {
|
|
196
|
+
for (const gitlink of basisGitlinks(input.workspacePath, input.gitlinkBasis)) {
|
|
197
|
+
const populatedPrefix = `${gitlink.relativePath}/`;
|
|
198
|
+
const populated = [...entries.keys()].some((relativePath) => relativePath.startsWith(populatedPrefix));
|
|
199
|
+
if (entries.get(gitlink.relativePath)?.kind === "directory" && !populated) {
|
|
200
|
+
records.push(indexInfoRecord("160000", gitlink.objectId, gitlink.relativePath));
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
187
204
|
if (records.length > 0) {
|
|
188
205
|
git(input.workspacePath, ["update-index", "-z", "--index-info"], "populate workspace projection index", {
|
|
189
206
|
environment,
|
|
@@ -248,7 +265,8 @@ function synthesizeOursCommit(input) {
|
|
|
248
265
|
const mountTree = synthesizeMountTree({
|
|
249
266
|
workspacePath: input.workspacePath,
|
|
250
267
|
sourcePath: input.mount.sourcePath,
|
|
251
|
-
sourceMode: input.mount.sourceMode
|
|
268
|
+
sourceMode: input.mount.sourceMode,
|
|
269
|
+
gitlinkBasis: { basisHead: input.basisHead, workspaceRelativePath: input.workspaceRelativePath }
|
|
252
270
|
});
|
|
253
271
|
const rootTree = graftMountTree({
|
|
254
272
|
workspacePath: input.workspacePath,
|