gutterpress 0.10.0 → 0.10.1-beta.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/README.md +3 -16
- package/dist/api/index.d.ts +10 -19
- package/dist/api/index.js +8 -64
- package/dist/{audit-cvarpa72.js → audit-dce99css.js} +5 -5
- package/dist/{build-6r502chw.js → build-bj4x0727.js} +5 -5
- package/dist/checks/source/index.d.ts +1 -0
- package/dist/checks/source/merge-markers.d.ts +3 -0
- package/dist/{cli-cqtggsng.js → cli-0z6zf98d.js} +2 -47
- package/dist/{cli-eq5naw4m.js → cli-7n848af2.js} +370 -1249
- package/dist/{cli-zfcryxg8.js → cli-eewynen9.js} +97 -60
- package/dist/{cli-k1065rkg.js → cli-w692g6dx.js} +75 -29
- package/dist/{cli-149edp6b.js → cli-ydpf09d9.js} +1 -1
- package/dist/cli.js +14 -15
- package/dist/{doctor-akvxbtjb.js → doctor-7nd6n2aa.js} +2 -2
- package/dist/{engine-ft4cr3ep.js → engine-57vw8zpd.js} +1 -1
- package/dist/{engine-b159tbns.js → engine-8kdwy0jz.js} +2 -2
- package/dist/{gutterpress-viewer-te8g5grx.js → gutterpress-viewer-tma1qwz2.js} +57 -15
- package/dist/{index-ycpvr0am.js → index-7hrvksrb.js} +4 -4
- package/dist/{index-mdefp0y5.js → index-dtrftayr.js} +75 -27
- package/dist/{index-ge7q9xj3.js → index-h1x7krkg.js} +771 -1482
- package/dist/{index-wq3r5pj7.js → index-p0ebr7dh.js} +94 -57
- package/dist/index.js +9 -65
- package/dist/lib/git-fs.d.ts +43 -0
- package/dist/lib/host-policy.d.ts +14 -2
- package/dist/lib/remote-auth/clone.d.ts +0 -21
- package/dist/lib/remote-auth/converge-merge.d.ts +24 -7
- package/dist/lib/remote-auth/generic-auth.d.ts +0 -22
- package/dist/lib/remote-auth/git-http.d.ts +1 -1
- package/dist/lib/remote-auth/github-auth.d.ts +2 -22
- package/dist/lib/remote-auth/operation-log.d.ts +4 -9
- package/dist/lib/remote-auth/sync-messages.d.ts +35 -12
- package/dist/lib/remote-auth/sync-types.d.ts +30 -101
- package/dist/lib/remote-auth/sync.d.ts +19 -21
- package/dist/lib/remote-auth/token-store.d.ts +0 -10
- package/dist/lib/remote-auth/transport.d.ts +42 -40
- package/dist/lib/source-provider.d.ts +12 -0
- package/dist/{lint-p2sw53d9.js → lint-c8ze8sqw.js} +5 -5
- package/dist/{new-hvq0x91q.js → new-xy2qc300.js} +5 -5
- package/dist/{plugin-pssmk0dx.js → plugin-g9hwzjsm.js} +5 -5
- package/dist/{preflight-4j00yd0g.js → preflight-prcvdvmk.js} +5 -5
- package/dist/{preview-bridge-fz7vpk8m.js → preview-bridge-2nnrs2hy.js} +15 -0
- package/dist/{preview-d4s6gk6p.js → preview-h479apj9.js} +5 -5
- package/dist/{preview-interface-0ssk8bmm.js → preview-interface-2f5v96hd.js} +411 -88
- package/dist/{preview-shell-c5mfa3q0.js → preview-shell-kyjq59d9.js} +80 -25
- package/dist/{publish-tkc26en7.js → publish-emk644a8.js} +5 -5
- package/dist/{source-provider-3tcj6qg2.js → source-provider-2j5x2hyw.js} +1 -1
- package/dist/{source-provider-vanafrt9.js → source-provider-kn41jmbs.js} +1 -1
- package/dist/{validate-w9vfefrw.js → validate-be54bdc6.js} +5 -5
- package/package.json +1 -1
- package/dist/lib/app-heartbeat.d.ts +0 -102
- package/dist/lib/remote-auth/image-clash.d.ts +0 -17
- package/dist/lib/remote-auth/recovery/classify.d.ts +0 -97
- package/dist/lib/remote-auth/recovery/inspect.d.ts +0 -75
- package/dist/lib/remote-auth/recovery/locks.d.ts +0 -20
- package/dist/lib/remote-auth/recovery/repair.d.ts +0 -29
- package/dist/lib/remote-auth/recovery/types.d.ts +0 -39
- package/dist/repair-2va4w12t.js +0 -137
|
@@ -29,11 +29,11 @@
|
|
|
29
29
|
pageRangeOf: () => pageRangeOf,
|
|
30
30
|
pageOf: () => pageOf,
|
|
31
31
|
measure: () => measure,
|
|
32
|
+
makeOverflowFragmentable: () => makeOverflowFragmentable,
|
|
32
33
|
loadStyleSources: () => loadStyleSources,
|
|
33
34
|
injectViewerCss: () => injectViewerCss,
|
|
34
35
|
injectBreakMapping: () => injectBreakMapping,
|
|
35
36
|
fragmentDocument: () => fragmentDocument,
|
|
36
|
-
forcedColumnBreaksSupported: () => forcedColumnBreaksSupported,
|
|
37
37
|
contentEdgeRect: () => contentEdgeRect,
|
|
38
38
|
compensateTrailingMarginsBeforeAvoids: () => compensateTrailingMarginsBeforeAvoids,
|
|
39
39
|
compensateRepeatedHeaders: () => compensateRepeatedHeaders,
|
|
@@ -1048,15 +1048,10 @@
|
|
|
1048
1048
|
doc.getElementById("gp-break-mapping")?.remove();
|
|
1049
1049
|
return "";
|
|
1050
1050
|
}
|
|
1051
|
-
function forcedColumnBreaksSupported() {
|
|
1052
|
-
return typeof CSS !== "undefined" && typeof CSS.supports === "function" && CSS.supports("break-before", "column") && CSS.supports("break-after", "column");
|
|
1053
|
-
}
|
|
1054
1051
|
var FRAGMENT_EPSILON_PX = 1;
|
|
1055
1052
|
function contentEdgeRect(site, atEnd) {
|
|
1056
1053
|
const rects = Array.from(site.getClientRects());
|
|
1057
|
-
|
|
1058
|
-
const pool = solid.length ? solid : rects;
|
|
1059
|
-
return atEnd ? pool.at(-1) : pool[0];
|
|
1054
|
+
return atEnd ? rects.at(-1) : rects[0];
|
|
1060
1055
|
}
|
|
1061
1056
|
function columnReserve(offset, columnHeight) {
|
|
1062
1057
|
const remaining = columnHeight - offset;
|
|
@@ -1116,13 +1111,12 @@
|
|
|
1116
1111
|
continue;
|
|
1117
1112
|
const stripTop = strip.getBoundingClientRect().top;
|
|
1118
1113
|
const edge = prop === "break-after" ? rect.bottom : rect.top;
|
|
1119
|
-
|
|
1120
|
-
if (reserve === null)
|
|
1114
|
+
if (columnReserve((edge - stripTop) / cssZoomOf(strip), strip.clientHeight) === null)
|
|
1121
1115
|
continue;
|
|
1122
1116
|
const spacer = document.createElement("div");
|
|
1123
1117
|
spacer.className = "gp-column-break-spacer";
|
|
1124
1118
|
spacer.setAttribute("aria-hidden", "true");
|
|
1125
|
-
spacer.style.cssText =
|
|
1119
|
+
spacer.style.cssText = `${prop}: column; height:0; margin:0; padding:0; border:0;`;
|
|
1126
1120
|
if (prop === "break-after")
|
|
1127
1121
|
el.after(spacer);
|
|
1128
1122
|
else
|
|
@@ -1280,6 +1274,47 @@
|
|
|
1280
1274
|
delete el.dataset.gpLeadingPageRootDisplayPriority;
|
|
1281
1275
|
}
|
|
1282
1276
|
}
|
|
1277
|
+
var SCROLLABLE = /^(auto|scroll|hidden)$/;
|
|
1278
|
+
function makeOverflowFragmentable(strips) {
|
|
1279
|
+
const todo = [];
|
|
1280
|
+
for (const strip of strips) {
|
|
1281
|
+
for (const el of Array.from(strip.el.querySelectorAll("*"))) {
|
|
1282
|
+
const cs = getComputedStyle(el);
|
|
1283
|
+
const x = SCROLLABLE.test(cs.overflowX);
|
|
1284
|
+
const y = SCROLLABLE.test(cs.overflowY);
|
|
1285
|
+
if (x || y)
|
|
1286
|
+
todo.push({ el, x, y });
|
|
1287
|
+
}
|
|
1288
|
+
}
|
|
1289
|
+
for (const { el, x, y } of todo) {
|
|
1290
|
+
el.dataset.gpOverflow = "clipped";
|
|
1291
|
+
el.dataset.gpOverflowX = el.style.getPropertyValue("overflow-x");
|
|
1292
|
+
el.dataset.gpOverflowY = el.style.getPropertyValue("overflow-y");
|
|
1293
|
+
el.dataset.gpOverflowXPriority = el.style.getPropertyPriority("overflow-x");
|
|
1294
|
+
el.dataset.gpOverflowYPriority = el.style.getPropertyPriority("overflow-y");
|
|
1295
|
+
if (x)
|
|
1296
|
+
el.style.setProperty("overflow-x", "clip");
|
|
1297
|
+
if (y)
|
|
1298
|
+
el.style.setProperty("overflow-y", "clip");
|
|
1299
|
+
}
|
|
1300
|
+
}
|
|
1301
|
+
function restoreScrollContainers(doc = document) {
|
|
1302
|
+
for (const el of Array.from(doc.querySelectorAll('[data-gp-overflow="clipped"]'))) {
|
|
1303
|
+
for (const axis of ["x", "y"]) {
|
|
1304
|
+
const value = axis === "x" ? el.dataset.gpOverflowX : el.dataset.gpOverflowY;
|
|
1305
|
+
const priority = axis === "x" ? el.dataset.gpOverflowXPriority : el.dataset.gpOverflowYPriority;
|
|
1306
|
+
if (value)
|
|
1307
|
+
el.style.setProperty(`overflow-${axis}`, value, priority || "");
|
|
1308
|
+
else
|
|
1309
|
+
el.style.removeProperty(`overflow-${axis}`);
|
|
1310
|
+
}
|
|
1311
|
+
delete el.dataset.gpOverflow;
|
|
1312
|
+
delete el.dataset.gpOverflowX;
|
|
1313
|
+
delete el.dataset.gpOverflowY;
|
|
1314
|
+
delete el.dataset.gpOverflowXPriority;
|
|
1315
|
+
delete el.dataset.gpOverflowYPriority;
|
|
1316
|
+
}
|
|
1317
|
+
}
|
|
1283
1318
|
function compensateTrailingMarginsBeforeAvoids(model, strips) {
|
|
1284
1319
|
const candidates = new Set;
|
|
1285
1320
|
for (const decl of model.breaks) {
|
|
@@ -1555,11 +1590,15 @@
|
|
|
1555
1590
|
for (const [i, site] of sites.entries()) {
|
|
1556
1591
|
if (!plan[i])
|
|
1557
1592
|
continue;
|
|
1558
|
-
const
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1593
|
+
const leading = site.el.previousElementSibling;
|
|
1594
|
+
const need = leading?.classList.contains("gp-column-break-spacer") ? 1 : 2;
|
|
1595
|
+
for (let n = 0;n < need; n++) {
|
|
1596
|
+
const spacer = document.createElement("div");
|
|
1597
|
+
spacer.className = "gp-recto-spacer";
|
|
1598
|
+
spacer.setAttribute("aria-hidden", "true");
|
|
1599
|
+
spacer.style.cssText = "break-before: column; height: 0; margin: 0; padding: 0; border: 0;";
|
|
1600
|
+
site.el.before(spacer);
|
|
1601
|
+
}
|
|
1563
1602
|
inserted++;
|
|
1564
1603
|
}
|
|
1565
1604
|
return inserted;
|
|
@@ -1713,6 +1752,7 @@
|
|
|
1713
1752
|
const authoring = [];
|
|
1714
1753
|
const strips = buildStrips(model, opts, authoring);
|
|
1715
1754
|
await layoutReady;
|
|
1755
|
+
makeOverflowFragmentable(strips);
|
|
1716
1756
|
stabilizeFullHeightPageRoots(model, strips);
|
|
1717
1757
|
compensateTrailingMarginsBeforeAvoids(model, strips);
|
|
1718
1758
|
synthesizeColumnBreaks(model);
|
|
@@ -1735,12 +1775,14 @@
|
|
|
1735
1775
|
relayout: () => {
|
|
1736
1776
|
restoreFullHeightPageRoots();
|
|
1737
1777
|
restoreTrailingMargins();
|
|
1778
|
+
restoreScrollContainers();
|
|
1738
1779
|
unwrapStrips(strips);
|
|
1739
1780
|
for (const spacer of Array.from(document.querySelectorAll(".gp-recto-spacer")))
|
|
1740
1781
|
spacer.remove();
|
|
1741
1782
|
const rebuilt = buildStrips(model, opts, authoring);
|
|
1742
1783
|
strips.length = 0;
|
|
1743
1784
|
strips.push(...rebuilt);
|
|
1785
|
+
makeOverflowFragmentable(strips);
|
|
1744
1786
|
stabilizeFullHeightPageRoots(model, strips);
|
|
1745
1787
|
compensateTrailingMarginsBeforeAvoids(model, strips);
|
|
1746
1788
|
synthesizeColumnBreaks(model);
|
|
@@ -596,19 +596,19 @@ var favicon_default = "./favicon-wkbm9cjn.ico";
|
|
|
596
596
|
var manifest_schema_default = "./manifest.schema-zxgxnbg7.json";
|
|
597
597
|
|
|
598
598
|
// src/assets/preview/scripts/preview-interface.js
|
|
599
|
-
var preview_interface_default = "./preview-interface-
|
|
599
|
+
var preview_interface_default = "./preview-interface-2f5v96hd.js";
|
|
600
600
|
|
|
601
601
|
// src/assets/preview/scripts/preview-bridge.js
|
|
602
|
-
var preview_bridge_default = "./preview-bridge-
|
|
602
|
+
var preview_bridge_default = "./preview-bridge-2nnrs2hy.js";
|
|
603
603
|
|
|
604
604
|
// src/assets/preview/scripts/preview-shell.js
|
|
605
|
-
var preview_shell_default = "./preview-shell-
|
|
605
|
+
var preview_shell_default = "./preview-shell-kyjq59d9.js";
|
|
606
606
|
|
|
607
607
|
// profiles/CGATS21_CRPC1.icc
|
|
608
608
|
var CGATS21_CRPC1_default = "./CGATS21_CRPC1-g0e3k7kr.icc";
|
|
609
609
|
|
|
610
610
|
// src/assets/engine/gutterpress-viewer.js
|
|
611
|
-
var gutterpress_viewer_default = "./gutterpress-viewer-
|
|
611
|
+
var gutterpress_viewer_default = "./gutterpress-viewer-tma1qwz2.js";
|
|
612
612
|
|
|
613
613
|
// src/assets/engine/gutterpress-agent.js
|
|
614
614
|
var gutterpress_agent_default = "./gutterpress-agent-cazqstr1.js";
|
|
@@ -4,8 +4,59 @@ import {
|
|
|
4
4
|
findEnclosingRepoDir
|
|
5
5
|
} from "./index-v5mp7a6q.js";
|
|
6
6
|
|
|
7
|
+
// src/lib/git-fs.ts
|
|
8
|
+
import * as nodeFs from "node:fs";
|
|
9
|
+
var MUTABLE_GIT_METADATA = /(?:^|[\\/])\.git[\\/](?:index|HEAD|packed-refs|refs[\\/].+)$/;
|
|
10
|
+
function needsAtomicWrite(file) {
|
|
11
|
+
return typeof file === "string" && MUTABLE_GIT_METADATA.test(file);
|
|
12
|
+
}
|
|
13
|
+
var tempCounter = 0;
|
|
14
|
+
function tempPathFor(file) {
|
|
15
|
+
return `${file}.gp${process.pid.toString(36)}-${(tempCounter++).toString(36)}.tmp`;
|
|
16
|
+
}
|
|
17
|
+
function writeFile2(file, data, options, callback) {
|
|
18
|
+
const cb = typeof options === "function" ? options : callback;
|
|
19
|
+
const opts = typeof options === "function" ? undefined : options;
|
|
20
|
+
if (!needsAtomicWrite(file)) {
|
|
21
|
+
nodeFs.writeFile(file, data, opts, cb);
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
const temp = tempPathFor(file);
|
|
25
|
+
const failed = (err) => nodeFs.unlink(temp, () => cb(err));
|
|
26
|
+
nodeFs.writeFile(temp, data, opts, (writeErr) => {
|
|
27
|
+
if (writeErr)
|
|
28
|
+
return failed(writeErr);
|
|
29
|
+
nodeFs.rename(temp, file, (renameErr) => {
|
|
30
|
+
if (renameErr)
|
|
31
|
+
return failed(renameErr);
|
|
32
|
+
cb(null);
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
async function writeFilePromise(file, data, options) {
|
|
37
|
+
if (!needsAtomicWrite(file)) {
|
|
38
|
+
return nodeFs.promises.writeFile(file, data, options);
|
|
39
|
+
}
|
|
40
|
+
const temp = tempPathFor(file);
|
|
41
|
+
try {
|
|
42
|
+
await nodeFs.promises.writeFile(temp, data, options);
|
|
43
|
+
await nodeFs.promises.rename(temp, file);
|
|
44
|
+
} catch (err) {
|
|
45
|
+
await nodeFs.promises.unlink(temp).catch(() => {});
|
|
46
|
+
throw err;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
var promises2 = {
|
|
50
|
+
...nodeFs.promises,
|
|
51
|
+
writeFile: writeFilePromise
|
|
52
|
+
};
|
|
53
|
+
var gitFs = {
|
|
54
|
+
...nodeFs,
|
|
55
|
+
writeFile: writeFile2,
|
|
56
|
+
promises: promises2
|
|
57
|
+
};
|
|
58
|
+
|
|
7
59
|
// src/lib/source-provider.ts
|
|
8
|
-
import * as fs from "node:fs";
|
|
9
60
|
import path2 from "node:path";
|
|
10
61
|
import git from "isomorphic-git";
|
|
11
62
|
|
|
@@ -63,9 +114,6 @@ function formatData(data) {
|
|
|
63
114
|
}
|
|
64
115
|
return parts.length > 0 ? " " + parts.join(" ") : "";
|
|
65
116
|
}
|
|
66
|
-
function shortOid(oid) {
|
|
67
|
-
return oid.length >= 7 ? oid.slice(0, 7) : oid;
|
|
68
|
-
}
|
|
69
117
|
|
|
70
118
|
// src/lib/source-provider.ts
|
|
71
119
|
var noopLogger = {
|
|
@@ -86,7 +134,7 @@ var repoQueues = new Map;
|
|
|
86
134
|
function repoLockKey(projectDir) {
|
|
87
135
|
const resolved = path2.resolve(projectDir);
|
|
88
136
|
try {
|
|
89
|
-
return
|
|
137
|
+
return gitFs.realpathSync(resolved);
|
|
90
138
|
} catch {
|
|
91
139
|
return resolved;
|
|
92
140
|
}
|
|
@@ -117,10 +165,10 @@ function gitAuthor(name, email) {
|
|
|
117
165
|
}
|
|
118
166
|
async function readGitAuthor(dir) {
|
|
119
167
|
const [name, email] = await Promise.all([
|
|
120
|
-
git.getConfig({ fs, dir, path: "user.name" }).catch(() => {
|
|
168
|
+
git.getConfig({ fs: gitFs, dir, path: "user.name" }).catch(() => {
|
|
121
169
|
return;
|
|
122
170
|
}),
|
|
123
|
-
git.getConfig({ fs, dir, path: "user.email" }).catch(() => {
|
|
171
|
+
git.getConfig({ fs: gitFs, dir, path: "user.email" }).catch(() => {
|
|
124
172
|
return;
|
|
125
173
|
})
|
|
126
174
|
]);
|
|
@@ -137,14 +185,14 @@ async function listWorkdirChanges(dir, cache = {}) {
|
|
|
137
185
|
const adds = [];
|
|
138
186
|
const removes = [];
|
|
139
187
|
await git.walk({
|
|
140
|
-
fs,
|
|
188
|
+
fs: gitFs,
|
|
141
189
|
dir,
|
|
142
190
|
cache,
|
|
143
191
|
trees: [git.WORKDIR(), git.STAGE()],
|
|
144
192
|
map: async (filepath, [workdir, stage]) => {
|
|
145
193
|
if (filepath === ".")
|
|
146
194
|
return;
|
|
147
|
-
if (!stage && workdir && await git.isIgnored({ fs, dir, filepath })) {
|
|
195
|
+
if (!stage && workdir && (filepath.startsWith(".git-damaged") || await git.isIgnored({ fs: gitFs, dir, filepath }))) {
|
|
148
196
|
return null;
|
|
149
197
|
}
|
|
150
198
|
const [wType, sType] = await Promise.all([
|
|
@@ -168,7 +216,7 @@ async function listWorkdirChanges(dir, cache = {}) {
|
|
|
168
216
|
if (workdirOid !== stageOid) {
|
|
169
217
|
adds.push(filepath);
|
|
170
218
|
} else {
|
|
171
|
-
const fileBytes = await
|
|
219
|
+
const fileBytes = await gitFs.promises.readFile(path2.join(dir, filepath));
|
|
172
220
|
const { oid: actualOid } = await git.hashBlob({ object: fileBytes });
|
|
173
221
|
if (actualOid !== stageOid)
|
|
174
222
|
adds.push(filepath);
|
|
@@ -181,10 +229,10 @@ async function listWorkdirChanges(dir, cache = {}) {
|
|
|
181
229
|
}
|
|
182
230
|
async function stageChanges(dir, changes, cache) {
|
|
183
231
|
if (changes.adds.length > 0) {
|
|
184
|
-
await git.add({ fs, dir, cache, filepath: changes.adds });
|
|
232
|
+
await git.add({ fs: gitFs, dir, cache, filepath: changes.adds });
|
|
185
233
|
}
|
|
186
234
|
for (const filepath of changes.removes) {
|
|
187
|
-
await git.remove({ fs, dir, cache, filepath });
|
|
235
|
+
await git.remove({ fs: gitFs, dir, cache, filepath });
|
|
188
236
|
}
|
|
189
237
|
}
|
|
190
238
|
async function hasPendingChanges(dir, cache = {}) {
|
|
@@ -199,13 +247,13 @@ async function hasUncommittedChanges(dir, cache = {}) {
|
|
|
199
247
|
async function stageMatchesHead(dir, cache) {
|
|
200
248
|
let headOid;
|
|
201
249
|
try {
|
|
202
|
-
headOid = await git.resolveRef({ fs, dir, ref: "HEAD" });
|
|
250
|
+
headOid = await git.resolveRef({ fs: gitFs, dir, ref: "HEAD" });
|
|
203
251
|
} catch {
|
|
204
252
|
return false;
|
|
205
253
|
}
|
|
206
254
|
let differs = false;
|
|
207
255
|
await git.walk({
|
|
208
|
-
fs,
|
|
256
|
+
fs: gitFs,
|
|
209
257
|
dir,
|
|
210
258
|
cache,
|
|
211
259
|
trees: [git.TREE({ ref: headOid }), git.STAGE()],
|
|
@@ -247,10 +295,10 @@ class LocalFolderSourceProvider {
|
|
|
247
295
|
}
|
|
248
296
|
return withRepoLock(dir, async () => {
|
|
249
297
|
const cache = {};
|
|
250
|
-
await git.init({ fs, dir, defaultBranch: DEFAULT_BRANCH });
|
|
298
|
+
await git.init({ fs: gitFs, dir, defaultBranch: DEFAULT_BRANCH });
|
|
251
299
|
await stageChanges(dir, await listWorkdirChanges(dir, cache), cache);
|
|
252
300
|
await git.commit({
|
|
253
|
-
fs,
|
|
301
|
+
fs: gitFs,
|
|
254
302
|
dir,
|
|
255
303
|
cache,
|
|
256
304
|
message: options.initialMessage?.trim() || "Created project",
|
|
@@ -319,7 +367,7 @@ class LocalGitSourceProvider {
|
|
|
319
367
|
let commits;
|
|
320
368
|
try {
|
|
321
369
|
commits = await git.log({
|
|
322
|
-
fs,
|
|
370
|
+
fs: gitFs,
|
|
323
371
|
dir,
|
|
324
372
|
cache: {},
|
|
325
373
|
depth: limit + 2,
|
|
@@ -356,7 +404,7 @@ class LocalGitSourceProvider {
|
|
|
356
404
|
}
|
|
357
405
|
async restoreUnlocked(options) {
|
|
358
406
|
await git.checkout({
|
|
359
|
-
fs,
|
|
407
|
+
fs: gitFs,
|
|
360
408
|
dir: this.dir,
|
|
361
409
|
cache: {},
|
|
362
410
|
ref: options.id,
|
|
@@ -368,9 +416,9 @@ class LocalGitSourceProvider {
|
|
|
368
416
|
async function snapshotWorkingTreeUnlocked(options) {
|
|
369
417
|
const dir = options.repoRoot ?? options.projectDir;
|
|
370
418
|
const logger = options.logFile ? createFileLogger(options.logFile, "snapshot") : noopLogger;
|
|
371
|
-
const cache = {};
|
|
419
|
+
const cache = options.cache ?? {};
|
|
372
420
|
const stagingMarker = snapshotStagingMarkerPath(dir);
|
|
373
|
-
const staleStaging =
|
|
421
|
+
const staleStaging = gitFs.existsSync(stagingMarker);
|
|
374
422
|
const changes = await listWorkdirChanges(dir, cache);
|
|
375
423
|
const workdirClean = changes.adds.length === 0 && changes.removes.length === 0;
|
|
376
424
|
if (workdirClean && !staleStaging) {
|
|
@@ -379,8 +427,8 @@ async function snapshotWorkingTreeUnlocked(options) {
|
|
|
379
427
|
}
|
|
380
428
|
if (workdirClean && staleStaging && await stageMatchesHead(dir, cache)) {
|
|
381
429
|
logger.debug("snapshot", "stale marker outlived a completed commit — clearing, not recommitting");
|
|
382
|
-
|
|
383
|
-
const [head2] = await git.log({ fs, dir, cache, depth: 1 });
|
|
430
|
+
gitFs.rmSync(stagingMarker, { force: true });
|
|
431
|
+
const [head2] = await git.log({ fs: gitFs, dir, cache, depth: 1 });
|
|
384
432
|
return {
|
|
385
433
|
id: head2.oid,
|
|
386
434
|
message: head2.commit.message.trim(),
|
|
@@ -393,18 +441,18 @@ async function snapshotWorkingTreeUnlocked(options) {
|
|
|
393
441
|
removes: changes.removes.length,
|
|
394
442
|
...staleStaging ? { recoveredStaleStaging: true } : {}
|
|
395
443
|
});
|
|
396
|
-
|
|
444
|
+
gitFs.writeFileSync(stagingMarker, "");
|
|
397
445
|
await stageChanges(dir, changes, cache);
|
|
398
446
|
const author = await resolveGitAuthor(dir, options.authorName, options.authorEmail);
|
|
399
447
|
const id = await git.commit({
|
|
400
|
-
fs,
|
|
448
|
+
fs: gitFs,
|
|
401
449
|
dir,
|
|
402
450
|
cache,
|
|
403
451
|
message: options.message,
|
|
404
452
|
author
|
|
405
453
|
});
|
|
406
|
-
|
|
407
|
-
const [head] = await git.log({ fs, dir, cache, depth: 1 });
|
|
454
|
+
gitFs.rmSync(stagingMarker, { force: true });
|
|
455
|
+
const [head] = await git.log({ fs: gitFs, dir, cache, depth: 1 });
|
|
408
456
|
return {
|
|
409
457
|
id,
|
|
410
458
|
message: options.message,
|
|
@@ -461,4 +509,4 @@ async function restoreVersionWithBackup(options) {
|
|
|
461
509
|
});
|
|
462
510
|
}
|
|
463
511
|
|
|
464
|
-
export {
|
|
512
|
+
export { gitFs, resolveLogger, gitScopeFor, HISTORY_PAGE_LIMIT, withRepoLock, __repoLockQueueSizeForTests, resolveGitAuthor, listWorkdirChanges, stageChanges, hasPendingChanges, hasUncommittedChanges, snapshotWorkingTreeUnlocked, isNoChangesError, providerFor, gitDirFor, snapshotStagingMarkerPath, RESTORE_BACKUP_MESSAGE, AUTO_SNAPSHOT_MESSAGE, restoreVersionWithBackup };
|