reslop 0.2.3 → 0.2.4

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.
Files changed (80) hide show
  1. package/CHANGELOG.md +14 -1
  2. package/README.md +8 -3
  3. package/bin/reslop.js +4 -2
  4. package/lib/api.js +2 -1
  5. package/lib/cli.js +19 -10
  6. package/lib/clipboard.js +6 -3
  7. package/lib/deps-diff.js +61 -115
  8. package/lib/deps.js +24 -61
  9. package/lib/detect.js +4 -2
  10. package/lib/diff/align.js +2 -1
  11. package/lib/diff/diff.js +6 -3
  12. package/lib/diff/display.js +2 -1
  13. package/lib/diff/inline.js +2 -1
  14. package/lib/diff/patch.js +2 -1
  15. package/lib/diff/unit.js +4 -2
  16. package/lib/editor.js +22 -4
  17. package/lib/files.js +38 -12
  18. package/lib/git-branches.js +107 -154
  19. package/lib/git-deps.js +20 -60
  20. package/lib/git-worktree.js +508 -0
  21. package/lib/git.js +23 -580
  22. package/lib/github.js +2 -1
  23. package/lib/gitlab.js +2 -1
  24. package/lib/highlight/bash.js +2 -1
  25. package/lib/highlight/css.js +2 -1
  26. package/lib/highlight/csv.js +2 -1
  27. package/lib/highlight/dot.js +2 -1
  28. package/lib/highlight/html.js +2 -1
  29. package/lib/highlight/json.js +2 -1
  30. package/lib/highlight/log.js +2 -1
  31. package/lib/highlight/txt.js +2 -1
  32. package/lib/highlight.js +2 -1
  33. package/lib/keys.js +2 -2
  34. package/lib/manifest.js +4 -2
  35. package/lib/npm-commands.js +83 -4
  36. package/lib/remote.js +20 -13
  37. package/lib/render/branches.js +6 -15
  38. package/lib/render/chrome.js +27 -7
  39. package/lib/render/commits.js +158 -46
  40. package/lib/render/diff.js +130 -47
  41. package/lib/render/files.js +4 -12
  42. package/lib/render/frame.js +3 -9
  43. package/lib/render/notes.js +4 -11
  44. package/lib/render/npm.js +1 -13
  45. package/lib/render/present.js +2 -1
  46. package/lib/render/primitives.js +28 -15
  47. package/lib/render/render.js +2 -1
  48. package/lib/render/unit.js +14 -11
  49. package/lib/report-model.js +6 -4
  50. package/lib/report-parse.js +8 -13
  51. package/lib/report-render.js +38 -21
  52. package/lib/report-run.js +12 -10
  53. package/lib/report-test.js +5 -4
  54. package/lib/report-tools.js +44 -18
  55. package/lib/review-merge.js +2 -1
  56. package/lib/review.js +6 -2
  57. package/lib/session/actions.js +49 -65
  58. package/lib/session/branches.js +13 -49
  59. package/lib/session/change-actions.js +2 -1
  60. package/lib/session/commit.js +34 -49
  61. package/lib/session/compose.js +37 -11
  62. package/lib/session/dispatch.js +17 -25
  63. package/lib/session/files-pane.js +6 -27
  64. package/lib/session/items.js +6 -3
  65. package/lib/session/lifecycle.js +8 -4
  66. package/lib/session/load.js +4 -2
  67. package/lib/session/navigation.js +1 -0
  68. package/lib/session/npm.js +54 -1
  69. package/lib/session/ops.js +15 -1
  70. package/lib/session/pointer.js +22 -3
  71. package/lib/session/review.js +2 -1
  72. package/lib/session/terminal.js +4 -2
  73. package/lib/session/update.js +2 -1
  74. package/lib/session/view.js +29 -3
  75. package/lib/session.js +37 -23
  76. package/lib/source.js +6 -3
  77. package/lib/update.js +5 -9
  78. package/lib/utilities.js +4 -2
  79. package/lib/wrap.js +3 -1
  80. package/package.json +1 -1
package/lib/git.js CHANGED
@@ -1,534 +1,11 @@
1
1
  'use strict';
2
2
 
3
- const fs = require('node:fs');
4
- const path = require('node:path');
5
-
6
- const proc = require('./utilities.js');
7
- const { runProc, runProcSync, isAbort } = proc;
8
- const { capabilitiesFor, attachCapabilities } = require('./capabilities.js');
9
- const diff = require('./diff/diff.js');
10
- const { parseDiff, synthesizeNewFile, itemsFromFiles } = diff;
11
- const { itemPath, REVIEW_DIR } = require('./files.js');
12
- const { replaceBlockAdds } = require('./diff/edit.js');
13
-
14
- const oneLine = (text, fallback = 'git failed') => proc.oneLine(text, fallback);
15
-
16
- const GIT_CONFIG = [
17
- '-c',
18
- 'core.quotepath=false',
19
- '-c',
20
- 'i18n.logOutputEncoding=utf-8',
21
- ];
22
- const DIFF_OPTS = ['--no-color', '--no-ext-diff', '--no-renames', '-U3'];
23
- const GIT_ENCODING = proc.DEFAULT_ENCODING;
24
- const GIT_MAX_BUFFER = proc.DEFAULT_MAX_BUFFER;
25
-
26
- const gitProcOptions = (cwd, extra = {}) => ({
27
- cwd,
28
- env: { ...process.env, GIT_OPTIONAL_LOCKS: '0', ...extra.env },
29
- encoding: GIT_ENCODING,
30
- maxBuffer: GIT_MAX_BUFFER,
31
- input: extra.input,
32
- signal: extra.signal,
33
- });
34
-
35
- const gitResult = (result) => {
36
- if (!result.error) return result;
37
- if (isAbort(result.error)) throw result.error;
38
- if (result.error.code === 'ENOENT') throw new Error('git not found');
39
- throw result.error;
40
- };
41
-
42
- const requireOk = (result, fallback = 'git failed') => {
43
- if (result.status === 0) return result;
44
- const msg = result.stderr || result.stdout || fallback;
45
- throw new Error(oneLine(msg, fallback));
46
- };
47
-
48
- const runGit = (args, cwd, input, extra = {}) => {
49
- const options = gitProcOptions(cwd, { input, env: extra.env });
50
- return gitResult(runProcSync('git', args, options));
51
- };
52
-
53
- const runGitAsync = (args, cwd, extra = {}) => {
54
- const options = gitProcOptions(cwd, extra);
55
- return runProc('git', args, options).then(gitResult);
56
- };
57
-
58
- const pathArgsOf = (paths) => (paths.length ? ['--', ...paths] : []);
59
-
60
- const cachedDiffArgs = (pathArgs) => [
61
- ...GIT_CONFIG,
62
- 'diff',
63
- '--cached',
64
- ...DIFF_OPTS,
65
- ...pathArgs,
66
- ];
67
-
68
- const worktreeDiffArgs = (pathArgs) => [
69
- ...GIT_CONFIG,
70
- 'diff',
71
- ...DIFF_OPTS,
72
- ...pathArgs,
73
- ];
74
-
75
- const commitDiffArgs = (commit, parent, pathArgs) => {
76
- if (parent.status === 0) {
77
- const from = parent.stdout.trim();
78
- return [...GIT_CONFIG, 'diff', ...DIFF_OPTS, from, commit, ...pathArgs];
79
- }
80
- return [
81
- ...GIT_CONFIG,
82
- 'diff-tree',
83
- '--no-commit-id',
84
- '--root',
85
- '-p',
86
- ...DIFF_OPTS,
87
- commit,
88
- ...pathArgs,
89
- ];
90
- };
91
-
92
- const BINARY_SIZE = 1000000;
93
-
94
- const isReviewFile = (rel) => {
95
- if (!rel) return false;
96
- const first = rel.split(/[/\\]/)[0];
97
- return first === REVIEW_DIR;
98
- };
99
-
100
- const dropReviewItems = (items) => {
101
- const kept = [];
102
- for (const item of items) {
103
- if (isReviewFile(itemPath(item))) continue;
104
- kept.push(item);
105
- }
106
- return kept;
107
- };
108
-
109
- const isBinaryBuffer = (buf) => {
110
- if (buf.length > BINARY_SIZE) return true;
111
- return buf.includes(0);
112
- };
113
-
114
- const namesFromLs = (stdout) => {
115
- if (!stdout) return [];
116
- return stdout.split('\0').filter(Boolean);
117
- };
118
-
119
- const untrackedLsArgs = (paths) => {
120
- const args = ['ls-files', '-o', '--exclude-standard', '-z'];
121
- if (paths.length) args.push('--', ...paths);
122
- return args;
123
- };
124
-
125
- const listUntracked = (top, paths) => {
126
- const result = requireOk(runGit(untrackedLsArgs(paths), top));
127
- return namesFromLs(result.stdout);
128
- };
129
-
130
- const filterListed = (names) => {
131
- const out = [];
132
- for (const rel of names) {
133
- if (!rel || isReviewFile(rel)) continue;
134
- out.push(rel);
135
- }
136
- return out;
137
- };
138
-
139
- const listTreeArgs = (rev, paths) => {
140
- const args = ['ls-tree', '-r', '--name-only', '-z', rev];
141
- if (paths.length) args.push('--', ...paths);
142
- return args;
143
- };
144
-
145
- const listWorktreeArgs = (paths) => {
146
- const args = ['ls-files', '-co', '--exclude-standard', '-z'];
147
- if (paths.length) args.push('--', ...paths);
148
- return args;
149
- };
150
-
151
- const listScopeFiles = (top, paths = [], options = {}) => {
152
- const rev = options.commit;
153
- const args = rev ? listTreeArgs(rev, paths) : listWorktreeArgs(paths);
154
- const result = requireOk(runGit(args, top), 'ls-files failed');
155
- const names = filterListed(namesFromLs(result.stdout));
156
- names.sort((left, right) => left.localeCompare(right, 'en'));
157
- return names;
158
- };
159
-
160
- const binaryNewFile = (rel) => ({
161
- oldPath: rel,
162
- newPath: rel,
163
- isNew: true,
164
- isDeleted: false,
165
- isBinary: true,
166
- preamble: [`diff --git a/${rel} b/${rel}`, 'new file mode 100644'],
167
- hunks: [],
168
- });
169
-
170
- const untrackedItemsFrom = (top, names) => {
171
- const files = [];
172
- for (const rel of names) {
173
- if (isReviewFile(rel)) continue;
174
- const full = path.join(top, rel);
175
- let buf;
176
- try {
177
- buf = fs.readFileSync(full);
178
- } catch (error) {
179
- if (error.code === 'ENOENT') continue;
180
- throw error;
181
- }
182
- if (isBinaryBuffer(buf)) {
183
- files.push(binaryNewFile(rel));
184
- continue;
185
- }
186
- files.push(synthesizeNewFile(rel, buf.toString('utf8')));
187
- }
188
- return itemsFromFiles(files, 'untracked');
189
- };
190
-
191
- const mergeItems = (groups) => {
192
- const byPath = new Map();
193
- for (const group of groups) {
194
- for (const item of group) {
195
- const rel = itemPath(item);
196
- const list = byPath.get(rel);
197
- if (list) {
198
- list.push(item);
199
- continue;
200
- }
201
- byPath.set(rel, [item]);
202
- }
203
- }
204
- let size = 0;
205
- for (const list of byPath.values()) size += list.length;
206
- const items = new Array(size);
207
- let i = 0;
208
- for (const list of byPath.values()) {
209
- for (const item of list) items[i++] = item;
210
- }
211
- return items;
212
- };
213
-
214
- const gitText = (top, spec) => {
215
- const result = runGit(['show', spec], top);
216
- if (result.status !== 0) return '';
217
- return result.stdout ?? '';
218
- };
219
-
220
- const worktreeText = (top, rel) => {
221
- try {
222
- return fs.readFileSync(path.join(top, rel), 'utf8');
223
- } catch {
224
- return '';
225
- }
226
- };
227
-
228
- const fileText = (top, rel, rev) => {
229
- if (!rel) return '';
230
- if (rev) return gitText(top, `${rev}:${rel}`);
231
- return worktreeText(top, rel);
232
- };
233
-
234
- const readDepSides = (top, rev, origin, rel) => {
235
- if (origin === 'untracked') {
236
- const newText = worktreeText(top, rel);
237
- return { oldText: '', newText };
238
- }
239
- if (origin === 'staged') {
240
- const oldText = gitText(top, `HEAD:${rel}`);
241
- const newText = gitText(top, `:${rel}`);
242
- return { oldText, newText };
243
- }
244
- if (origin === 'unstaged') {
245
- const indexed = gitText(top, `:${rel}`);
246
- const oldText = indexed || gitText(top, `HEAD:${rel}`);
247
- const newText = worktreeText(top, rel);
248
- return { oldText, newText };
249
- }
250
- if (origin === 'commit' && rev) {
251
- const oldText = gitText(top, `${rev}^:${rel}`);
252
- const newText = gitText(top, `${rev}:${rel}`);
253
- return { oldText, newText };
254
- }
255
- return { oldText: '', newText: '' };
256
- };
257
-
258
- const toplevel = (cwd) => {
259
- const result = runGit(['rev-parse', '--show-toplevel'], cwd);
260
- if (result.status !== 0) throw new Error('not a git repository');
261
- return result.stdout.trim();
262
- };
263
-
264
- const resolveRev = (cwd, spec) => {
265
- if (!spec) return null;
266
- const top = toplevel(cwd);
267
- const args = ['rev-parse', '--verify', `${spec}^{commit}`];
268
- const result = runGit(args, top);
269
- if (result.status !== 0) return null;
270
- return result.stdout.trim();
271
- };
272
-
273
- const shortRev = (top, commit) => {
274
- const result = runGit(['rev-parse', '--short', commit], top);
275
- if (result.status !== 0) return commit.slice(0, 7);
276
- return result.stdout.trim();
277
- };
278
-
279
- const currentBranch = (top) => {
280
- const args = ['rev-parse', '--abbrev-ref', 'HEAD'];
281
- const result = runGit(args, top);
282
- if (result.status !== 0) return '';
283
- const name = result.stdout.trim();
284
- if (!name || name === 'HEAD') return '';
285
- return name;
286
- };
287
-
288
- const snapshotWorktree = (top, stagedOut, unstagedOut, names) => {
289
- const stagedDiff = parseDiff(stagedOut);
290
- const unstagedDiff = parseDiff(unstagedOut);
291
- const staged = itemsFromFiles(stagedDiff, 'staged');
292
- const unstaged = itemsFromFiles(unstagedDiff, 'unstaged');
293
- const untracked = untrackedItemsFrom(top, names);
294
- const combined = mergeItems([staged, unstaged, untracked]);
295
- const parsed = dropReviewItems(combined);
296
- const branch = currentBranch(top);
297
- return { top, parsed, branch };
298
- };
299
-
300
- const snapshotCommit = (top, commit, files) => {
301
- const commitItems = itemsFromFiles(files, 'commit');
302
- const parsed = dropReviewItems(commitItems);
303
- const revShort = shortRev(top, commit);
304
- const branch = currentBranch(top);
305
- return { top, parsed, rev: commit, revShort, branch };
306
- };
307
-
308
- const loadCommit = (top, commit, extra) => {
309
- const parent = runGit(['rev-parse', '--verify', `${commit}^`], top);
310
- const args = commitDiffArgs(commit, parent, extra);
311
- const result = requireOk(runGit(args, top));
312
- return parseDiff(result.stdout);
313
- };
314
-
315
- const loadCommitAsync = async (top, commit, extra, signal) => {
316
- const parent = await runGitAsync(
317
- ['rev-parse', '--verify', `${commit}^`],
318
- top,
319
- { signal },
320
- );
321
- const args = commitDiffArgs(commit, parent, extra);
322
- const result = requireOk(await runGitAsync(args, top, { signal }));
323
- return parseDiff(result.stdout);
324
- };
325
-
326
- const readSnapshot = (cwd, paths, options) => {
327
- const top = toplevel(cwd);
328
- const extra = pathArgsOf(paths);
329
- const rev = options.commit;
330
- if (rev) return snapshotCommit(top, rev, loadCommit(top, rev, extra));
331
- const stagedRes = requireOk(runGit(cachedDiffArgs(extra), top));
332
- const unstagedRes = requireOk(runGit(worktreeDiffArgs(extra), top));
333
- const names = listUntracked(top, paths);
334
- return snapshotWorktree(top, stagedRes.stdout, unstagedRes.stdout, names);
335
- };
336
-
337
- const readSnapshotAsync = async (cwd, paths, options) => {
338
- const top = toplevel(cwd);
339
- const extra = pathArgsOf(paths);
340
- const rev = options.commit;
341
- const signal = options.signal;
342
- if (rev) {
343
- const files = await loadCommitAsync(top, rev, extra, signal);
344
- return snapshotCommit(top, rev, files);
345
- }
346
- const stagedArgs = cachedDiffArgs(extra);
347
- const unstagedArgs = worktreeDiffArgs(extra);
348
- const lsArgs = untrackedLsArgs(paths);
349
- const stagedP = runGitAsync(stagedArgs, top, { signal });
350
- const unstagedP = runGitAsync(unstagedArgs, top, { signal });
351
- const lsP = runGitAsync(lsArgs, top, { signal });
352
- const extras = await Promise.all([stagedP, unstagedP, lsP]);
353
- const stagedRes = extras[0];
354
- const unstagedRes = extras[1];
355
- const lsRes = extras[2];
356
- requireOk(stagedRes);
357
- requireOk(unstagedRes);
358
- const names = namesFromLs(requireOk(lsRes).stdout);
359
- return snapshotWorktree(top, stagedRes.stdout, unstagedRes.stdout, names);
360
- };
361
-
362
- const applyPatch = (cwd, patch, flags) => {
363
- const args = ['apply', ...flags, '--whitespace=nowarn', '-'];
364
- const result = runGit(args, cwd, patch);
365
- requireOk(result, 'apply failed');
366
- };
367
-
368
- const addItem = (top, item) => {
369
- if (item.origin === 'staged' || item.origin === 'commit') return;
370
- if (item.origin === 'untracked' || item.file.isBinary) {
371
- return void requireOk(runGit(['add', '--', item.file.newPath], top));
372
- }
373
- applyPatch(top, item.patchAdd, ['--cached']);
374
- };
375
-
376
- const unstageItem = (top, item) => {
377
- if (item.origin !== 'staged') return;
378
- const rel = itemPath(item);
379
- if (item.file.isBinary) {
380
- return void requireOk(runGit(['restore', '--staged', '--', rel], top));
381
- }
382
- applyPatch(top, item.patchAdd, ['--reverse', '--cached']);
383
- };
384
-
385
- const revertOnePath = (top, rel, items) => {
386
- const origins = new Set();
387
- let isNew = false;
388
- for (const item of items) {
389
- origins.add(item.origin);
390
- if (item.file && item.file.isNew) isNew = true;
391
- }
392
- if (isNew) {
393
- if (origins.has('staged')) {
394
- return void requireOk(runGit(['rm', '-f', '--', rel], top));
395
- }
396
- return void fs.unlinkSync(path.join(top, rel));
397
- }
398
- if (origins.has('untracked') && origins.size === 1) {
399
- return void fs.unlinkSync(path.join(top, rel));
400
- }
401
- const args = ['restore', '-s', 'HEAD', '--worktree', '--staged', '--', rel];
402
- requireOk(runGit(args, top));
403
- };
404
-
405
- const revertItem = (top, item) => {
406
- if (item.origin === 'commit') return;
407
- const rel = itemPath(item);
408
- if (item.origin === 'untracked') {
409
- return void fs.unlinkSync(path.join(top, rel));
410
- }
411
- if (item.file.isBinary) {
412
- const args = ['restore', '-s', 'HEAD', '--worktree'];
413
- if (item.origin === 'staged') args.push('--staged');
414
- args.push('--', rel);
415
- return void requireOk(runGit(args, top));
416
- }
417
- if (item.origin === 'unstaged') {
418
- return void applyPatch(top, item.patchRevert, ['--reverse']);
419
- }
420
- applyPatch(top, item.patchRevert, ['--reverse', '--cached']);
421
- try {
422
- applyPatch(top, item.patchRevert, ['--reverse']);
423
- } catch (error) {
424
- if (!error.message.includes('does not apply')) throw error;
425
- }
426
- };
427
-
428
- const revertFile = (top, rel, items) => {
429
- const group = [];
430
- for (const item of items) {
431
- if (itemPath(item) === rel) group.push(item);
432
- }
433
- const targets = group.length ? group : items;
434
- revertOnePath(top, rel, targets);
435
- };
436
-
437
- const indexText = (top, rel) => {
438
- const result = runGit(['show', `:${rel}`], top);
439
- requireOk(result, 'show failed');
440
- return result.stdout ?? '';
441
- };
442
-
443
- const indexMode = (top, rel) => {
444
- const result = runGit(['ls-files', '--stage', '--', rel], top);
445
- if (result.status !== 0) return '100644';
446
- const line = (result.stdout ?? '').trim();
447
- if (!line) return '100644';
448
- const mode = line.split(' ')[0];
449
- return mode || '100644';
450
- };
451
-
452
- const writeIndex = (top, rel, text) => {
453
- const hashed = runGit(['hash-object', '-w', '--stdin'], top, text);
454
- requireOk(hashed, 'hash-object failed');
455
- const sha = (hashed.stdout ?? '').trim();
456
- const mode = indexMode(top, rel);
457
- const args = ['update-index', '--cacheinfo', mode, sha, rel];
458
- requireOk(runGit(args, top), 'update-index failed');
459
- };
460
-
461
- const writeWorktree = (abs, text) => {
462
- fs.writeFileSync(abs, text);
463
- };
464
-
465
- const editStaged = (top, rel, abs, hunk, blockId, text) => {
466
- const source = indexText(top, rel);
467
- const next = replaceBlockAdds(source, hunk, blockId, text);
468
- writeIndex(top, rel, next);
469
- let work = null;
470
- try {
471
- work = fs.readFileSync(abs, 'utf8');
472
- } catch (error) {
473
- if (error.code !== 'ENOENT') throw error;
474
- }
475
- if (work === null) {
476
- return void writeWorktree(abs, next);
477
- }
478
- if (work === source) writeWorktree(abs, next);
479
- };
480
-
481
- const editWorktree = (abs, hunk, blockId, text) => {
482
- const source = fs.readFileSync(abs, 'utf8');
483
- const next = replaceBlockAdds(source, hunk, blockId, text);
484
- if (next === source) return;
485
- writeWorktree(abs, next);
486
- };
487
-
488
- const editItem = (top, item, text) => {
489
- if (item.origin === 'commit' || item.origin === 'pr') return;
490
- const rel = itemPath(item);
491
- if (!rel || !item.hunk) return;
492
- const abs = path.join(top, rel);
493
- if (item.origin === 'staged') {
494
- return void editStaged(top, rel, abs, item.hunk, item.blockId, text);
495
- }
496
- editWorktree(abs, item.hunk, item.blockId, text);
497
- };
498
-
499
- const writeFile = (top, rel, text) => {
500
- if (!rel) return;
501
- const abs = path.join(top, rel);
502
- fs.mkdirSync(path.dirname(abs), { recursive: true });
503
- writeWorktree(abs, text);
504
- };
505
-
506
- const stagePath = (top, rel) => {
507
- if (!rel) return;
508
- requireOk(runGit(['add', '--', rel], top));
509
- };
510
-
511
- module.exports = {
512
- oneLine,
513
- requireOk,
514
- runGit,
515
- runGitAsync,
516
- gitText,
517
- worktreeText,
518
- readDepSides,
519
- revertOnePath,
520
- toplevel,
521
- resolveRev,
522
- currentBranch,
523
- fileText,
524
- listScopeFiles,
525
- readSnapshot,
526
- readSnapshotAsync,
527
- editItem,
528
- writeFile,
529
- stagePath,
530
- };
531
-
3
+ const capabilities = require('./capabilities.js');
4
+ const { capabilitiesFor, attachCapabilities } = capabilities;
5
+ const worktree = require('./git-worktree.js');
6
+ const { readSnapshot, readSnapshotAsync, toplevel, resolveRev } = worktree;
7
+ const { listScopeFiles, fileText, editItem, writeFile, stagePath } = worktree;
8
+ const { addItem, unstageItem, revertItem, currentBranch } = worktree;
532
9
  const branches = require('./git-branches.js');
533
10
  const gitDeps = require('./git-deps.js');
534
11
 
@@ -547,38 +24,28 @@ const loadAsync = async (cwd, paths = [], options = {}) => {
547
24
  };
548
25
 
549
26
  const addGitItem = (top, item) => {
550
- if (gitDeps.handles(item)) return gitDeps.addItem(top, item);
27
+ if (item.dep) return gitDeps.addItem(top, item);
551
28
  return addItem(top, item);
552
29
  };
553
30
 
554
31
  const addGitItemAsync = async (top, item) => {
555
- if (gitDeps.handles(item)) {
556
- await gitDeps.addItemAsync(top, item);
557
- return;
558
- }
559
- addGitItem(top, item);
32
+ if (item.dep) return gitDeps.addItemAsync(top, item);
33
+ return addItem(top, item);
560
34
  };
561
35
 
562
36
  const unstageGitItem = (top, item) => {
563
- if (gitDeps.handles(item)) return gitDeps.unstageItem(top, item);
37
+ if (item.dep) return gitDeps.unstageItem(top, item);
564
38
  return unstageItem(top, item);
565
39
  };
566
40
 
567
41
  const revertGitItem = (top, item) => {
568
42
  if (item.origin === 'commit') return;
569
- if (gitDeps.handles(item)) {
43
+ if (item.dep) {
570
44
  return void gitDeps.revertDepItem(top, item);
571
45
  }
572
46
  revertItem(top, item);
573
47
  };
574
48
 
575
- const revertGitFile = (top, rel, items) => {
576
- if (gitDeps.relatedFiles(items).length) {
577
- return gitDeps.revertFile(top, rel, items);
578
- }
579
- return revertFile(top, rel, items);
580
- };
581
-
582
49
  const createGitRepo = () =>
583
50
  attachCapabilities(
584
51
  {
@@ -593,7 +60,7 @@ const createGitRepo = () =>
593
60
  addAsync: addGitItemAsync,
594
61
  unstage: unstageGitItem,
595
62
  revert: revertGitItem,
596
- revertFile: revertGitFile,
63
+ revertFile: gitDeps.revertFile,
597
64
  edit: editItem,
598
65
  writeFile,
599
66
  stagePath,
@@ -627,38 +94,14 @@ const createGitRepo = () =>
627
94
  capabilitiesFor('local'),
628
95
  );
629
96
 
630
- module.exports.load = load;
631
- module.exports.loadAsync = loadAsync;
632
- module.exports.loadExtras = gitDeps.loadExtras;
633
- module.exports.addItem = addGitItem;
634
- module.exports.unstageItem = unstageGitItem;
635
- module.exports.revertItem = revertGitItem;
636
- module.exports.editItem = editItem;
637
- module.exports.writeFile = writeFile;
638
- module.exports.commitChanges = branches.commitChanges;
639
- module.exports.commitChangesAsync = branches.commitChangesAsync;
640
- module.exports.hasStaged = branches.hasStaged;
641
- module.exports.currentBranch = currentBranch;
642
- module.exports.lastMessage = branches.lastMessage;
643
- module.exports.commitMessage = branches.commitMessage;
644
- module.exports.listBranches = branches.listBranches;
645
- module.exports.listCommits = branches.listCommits;
646
- module.exports.checkoutBranch = branches.checkoutBranch;
647
- module.exports.checkoutBranchAsync = branches.checkoutBranchAsync;
648
- module.exports.createBranch = branches.createBranch;
649
- module.exports.createBranchAsync = branches.createBranchAsync;
650
- module.exports.rebaseBranch = branches.rebaseBranch;
651
- module.exports.rebaseBranchAsync = branches.rebaseBranchAsync;
652
- module.exports.dropBranch = branches.dropBranch;
653
- module.exports.dropBranchAsync = branches.dropBranchAsync;
654
- module.exports.dropCommit = branches.dropCommit;
655
- module.exports.dropCommitAsync = branches.dropCommitAsync;
656
- module.exports.applyFixup = branches.applyFixup;
657
- module.exports.applyFixupAsync = branches.applyFixupAsync;
658
- module.exports.rewordCommit = branches.rewordCommit;
659
- module.exports.rewordCommitAsync = branches.rewordCommitAsync;
660
- module.exports.pullChanges = branches.pullChanges;
661
- module.exports.pullChangesAsync = branches.pullChangesAsync;
662
- module.exports.pushChanges = branches.pushChanges;
663
- module.exports.pushChangesAsync = branches.pushChangesAsync;
664
- module.exports.createGitRepo = createGitRepo;
97
+ module.exports = {
98
+ ...worktree,
99
+ ...branches,
100
+ load,
101
+ loadAsync,
102
+ loadExtras: gitDeps.loadExtras,
103
+ addItem: addGitItem,
104
+ unstageItem: unstageGitItem,
105
+ revertItem: revertGitItem,
106
+ createGitRepo,
107
+ };
package/lib/github.js CHANGED
@@ -1,6 +1,7 @@
1
1
  'use strict';
2
2
 
3
- const { isPathInScope } = require('./files.js');
3
+ const files = require('./files.js');
4
+ const { isPathInScope } = files;
4
5
  const remote = require('./remote.js');
5
6
  const { isRecord, isAbortError } = remote;
6
7
  const { createClient, listUrl, parseLinkNext } = remote;
package/lib/gitlab.js CHANGED
@@ -1,6 +1,7 @@
1
1
  'use strict';
2
2
 
3
- const { isPathInScope } = require('./files.js');
3
+ const files = require('./files.js');
4
+ const { isPathInScope } = files;
4
5
  const remote = require('./remote.js');
5
6
  const { isRecord } = remote;
6
7
  const { createClient, listUrl, parseNextPage } = remote;
@@ -1,6 +1,7 @@
1
1
  'use strict';
2
2
 
3
- const { SQUOTE, emit, wordStyle, readUntilNl } = require('./core.js');
3
+ const core = require('./core.js');
4
+ const { SQUOTE, emit, wordStyle, readUntilNl } = core;
4
5
 
5
6
  const BASH_QUOTE = `${SQUOTE}\``;
6
7
 
@@ -1,6 +1,7 @@
1
1
  'use strict';
2
2
 
3
- const { QUOTES, emit, readBlockComment, readString } = require('./core.js');
3
+ const core = require('./core.js');
4
+ const { QUOTES, emit, readBlockComment, readString } = core;
4
5
 
5
6
  const CSS_NEXT_STYLE = {
6
7
  ':': 'property',
@@ -1,6 +1,7 @@
1
1
  'use strict';
2
2
 
3
- const { emit } = require('./core.js');
3
+ const core = require('./core.js');
4
+ const { emit } = core;
4
5
 
5
6
  const splitCsv = (line) => {
6
7
  const cells = [];
@@ -1,6 +1,7 @@
1
1
  'use strict';
2
2
 
3
- const { emit } = require('./core.js');
3
+ const core = require('./core.js');
4
+ const { emit } = core;
4
5
 
5
6
  const highlightDotLine = (line) => {
6
7
  if (!line) return [];