@optique/git 0.9.0-dev.256 → 0.9.0-dev.260
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.cjs +44 -8
- package/dist/index.js +44 -8
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -44,7 +44,9 @@ const METAVAR_BRANCH = "BRANCH";
|
|
|
44
44
|
const METAVAR_TAG = "TAG";
|
|
45
45
|
const METAVAR_REMOTE = "REMOTE";
|
|
46
46
|
function getRepoDir(dirOption) {
|
|
47
|
-
|
|
47
|
+
if (dirOption != null) return dirOption;
|
|
48
|
+
if (typeof node_process.default !== "undefined" && typeof node_process.default.cwd === "function") return node_process.default.cwd();
|
|
49
|
+
throw new Error("Git parser requires a `dir` option in environments where `process.cwd()` is unavailable.");
|
|
48
50
|
}
|
|
49
51
|
function hasErrorCode(error, code) {
|
|
50
52
|
return typeof error === "object" && error !== null && "code" in error && error.code === code;
|
|
@@ -341,6 +343,23 @@ function gitCommit(options) {
|
|
|
341
343
|
error: __optique_core_message.message`Commit ${(0, __optique_core_message.value)(input)} does not exist. Provide a valid commit SHA.`
|
|
342
344
|
};
|
|
343
345
|
}
|
|
346
|
+
}, async function* suggestCommit(dir, prefix) {
|
|
347
|
+
try {
|
|
348
|
+
const commits = await isomorphic_git.log({
|
|
349
|
+
fs: gitFs,
|
|
350
|
+
dir,
|
|
351
|
+
depth: 15
|
|
352
|
+
});
|
|
353
|
+
for (const commit of commits) if (commit.oid.startsWith(prefix)) {
|
|
354
|
+
const shortOid = commit.oid.slice(0, 7);
|
|
355
|
+
const firstLine = commit.commit.message.split("\n")[0];
|
|
356
|
+
yield {
|
|
357
|
+
kind: "literal",
|
|
358
|
+
text: shortOid,
|
|
359
|
+
description: __optique_core_message.message`${firstLine}`
|
|
360
|
+
};
|
|
361
|
+
}
|
|
362
|
+
} catch {}
|
|
344
363
|
});
|
|
345
364
|
}
|
|
346
365
|
/**
|
|
@@ -390,13 +409,21 @@ function gitRef(options) {
|
|
|
390
409
|
}
|
|
391
410
|
}, async function* suggestRef(dir, prefix) {
|
|
392
411
|
try {
|
|
393
|
-
const [branches, tags] = await Promise.all([
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
412
|
+
const [branches, tags, commits] = await Promise.all([
|
|
413
|
+
isomorphic_git.listBranches({
|
|
414
|
+
fs: gitFs,
|
|
415
|
+
dir
|
|
416
|
+
}),
|
|
417
|
+
isomorphic_git.listTags({
|
|
418
|
+
fs: gitFs,
|
|
419
|
+
dir
|
|
420
|
+
}),
|
|
421
|
+
isomorphic_git.log({
|
|
422
|
+
fs: gitFs,
|
|
423
|
+
dir,
|
|
424
|
+
depth: 10
|
|
425
|
+
})
|
|
426
|
+
]);
|
|
400
427
|
for (const branch of branches) if (branch.startsWith(prefix)) yield {
|
|
401
428
|
kind: "literal",
|
|
402
429
|
text: branch
|
|
@@ -405,6 +432,15 @@ function gitRef(options) {
|
|
|
405
432
|
kind: "literal",
|
|
406
433
|
text: tag
|
|
407
434
|
};
|
|
435
|
+
for (const commit of commits) if (commit.oid.startsWith(prefix)) {
|
|
436
|
+
const shortOid = commit.oid.slice(0, 7);
|
|
437
|
+
const firstLine = commit.commit.message.split("\n")[0];
|
|
438
|
+
yield {
|
|
439
|
+
kind: "literal",
|
|
440
|
+
text: shortOid,
|
|
441
|
+
description: __optique_core_message.message`${firstLine}`
|
|
442
|
+
};
|
|
443
|
+
}
|
|
408
444
|
} catch {}
|
|
409
445
|
});
|
|
410
446
|
}
|
package/dist/index.js
CHANGED
|
@@ -22,7 +22,9 @@ const METAVAR_BRANCH = "BRANCH";
|
|
|
22
22
|
const METAVAR_TAG = "TAG";
|
|
23
23
|
const METAVAR_REMOTE = "REMOTE";
|
|
24
24
|
function getRepoDir(dirOption) {
|
|
25
|
-
|
|
25
|
+
if (dirOption != null) return dirOption;
|
|
26
|
+
if (typeof process !== "undefined" && typeof process.cwd === "function") return process.cwd();
|
|
27
|
+
throw new Error("Git parser requires a `dir` option in environments where `process.cwd()` is unavailable.");
|
|
26
28
|
}
|
|
27
29
|
function hasErrorCode(error, code) {
|
|
28
30
|
return typeof error === "object" && error !== null && "code" in error && error.code === code;
|
|
@@ -319,6 +321,23 @@ function gitCommit(options) {
|
|
|
319
321
|
error: message`Commit ${value(input)} does not exist. Provide a valid commit SHA.`
|
|
320
322
|
};
|
|
321
323
|
}
|
|
324
|
+
}, async function* suggestCommit(dir, prefix) {
|
|
325
|
+
try {
|
|
326
|
+
const commits = await git.log({
|
|
327
|
+
fs: gitFs,
|
|
328
|
+
dir,
|
|
329
|
+
depth: 15
|
|
330
|
+
});
|
|
331
|
+
for (const commit of commits) if (commit.oid.startsWith(prefix)) {
|
|
332
|
+
const shortOid = commit.oid.slice(0, 7);
|
|
333
|
+
const firstLine = commit.commit.message.split("\n")[0];
|
|
334
|
+
yield {
|
|
335
|
+
kind: "literal",
|
|
336
|
+
text: shortOid,
|
|
337
|
+
description: message`${firstLine}`
|
|
338
|
+
};
|
|
339
|
+
}
|
|
340
|
+
} catch {}
|
|
322
341
|
});
|
|
323
342
|
}
|
|
324
343
|
/**
|
|
@@ -368,13 +387,21 @@ function gitRef(options) {
|
|
|
368
387
|
}
|
|
369
388
|
}, async function* suggestRef(dir, prefix) {
|
|
370
389
|
try {
|
|
371
|
-
const [branches, tags] = await Promise.all([
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
390
|
+
const [branches, tags, commits] = await Promise.all([
|
|
391
|
+
git.listBranches({
|
|
392
|
+
fs: gitFs,
|
|
393
|
+
dir
|
|
394
|
+
}),
|
|
395
|
+
git.listTags({
|
|
396
|
+
fs: gitFs,
|
|
397
|
+
dir
|
|
398
|
+
}),
|
|
399
|
+
git.log({
|
|
400
|
+
fs: gitFs,
|
|
401
|
+
dir,
|
|
402
|
+
depth: 10
|
|
403
|
+
})
|
|
404
|
+
]);
|
|
378
405
|
for (const branch of branches) if (branch.startsWith(prefix)) yield {
|
|
379
406
|
kind: "literal",
|
|
380
407
|
text: branch
|
|
@@ -383,6 +410,15 @@ function gitRef(options) {
|
|
|
383
410
|
kind: "literal",
|
|
384
411
|
text: tag
|
|
385
412
|
};
|
|
413
|
+
for (const commit of commits) if (commit.oid.startsWith(prefix)) {
|
|
414
|
+
const shortOid = commit.oid.slice(0, 7);
|
|
415
|
+
const firstLine = commit.commit.message.split("\n")[0];
|
|
416
|
+
yield {
|
|
417
|
+
kind: "literal",
|
|
418
|
+
text: shortOid,
|
|
419
|
+
description: message`${firstLine}`
|
|
420
|
+
};
|
|
421
|
+
}
|
|
386
422
|
} catch {}
|
|
387
423
|
});
|
|
388
424
|
}
|