@optique/git 0.9.0-dev.256 → 0.9.0-dev.258

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 CHANGED
@@ -341,6 +341,23 @@ function gitCommit(options) {
341
341
  error: __optique_core_message.message`Commit ${(0, __optique_core_message.value)(input)} does not exist. Provide a valid commit SHA.`
342
342
  };
343
343
  }
344
+ }, async function* suggestCommit(dir, prefix) {
345
+ try {
346
+ const commits = await isomorphic_git.log({
347
+ fs: gitFs,
348
+ dir,
349
+ depth: 15
350
+ });
351
+ for (const commit of commits) if (commit.oid.startsWith(prefix)) {
352
+ const shortOid = commit.oid.slice(0, 7);
353
+ const firstLine = commit.commit.message.split("\n")[0];
354
+ yield {
355
+ kind: "literal",
356
+ text: shortOid,
357
+ description: __optique_core_message.message`${firstLine}`
358
+ };
359
+ }
360
+ } catch {}
344
361
  });
345
362
  }
346
363
  /**
@@ -390,13 +407,21 @@ function gitRef(options) {
390
407
  }
391
408
  }, async function* suggestRef(dir, prefix) {
392
409
  try {
393
- const [branches, tags] = await Promise.all([isomorphic_git.listBranches({
394
- fs: gitFs,
395
- dir
396
- }), isomorphic_git.listTags({
397
- fs: gitFs,
398
- dir
399
- })]);
410
+ const [branches, tags, commits] = await Promise.all([
411
+ isomorphic_git.listBranches({
412
+ fs: gitFs,
413
+ dir
414
+ }),
415
+ isomorphic_git.listTags({
416
+ fs: gitFs,
417
+ dir
418
+ }),
419
+ isomorphic_git.log({
420
+ fs: gitFs,
421
+ dir,
422
+ depth: 10
423
+ })
424
+ ]);
400
425
  for (const branch of branches) if (branch.startsWith(prefix)) yield {
401
426
  kind: "literal",
402
427
  text: branch
@@ -405,6 +430,15 @@ function gitRef(options) {
405
430
  kind: "literal",
406
431
  text: tag
407
432
  };
433
+ for (const commit of commits) if (commit.oid.startsWith(prefix)) {
434
+ const shortOid = commit.oid.slice(0, 7);
435
+ const firstLine = commit.commit.message.split("\n")[0];
436
+ yield {
437
+ kind: "literal",
438
+ text: shortOid,
439
+ description: __optique_core_message.message`${firstLine}`
440
+ };
441
+ }
408
442
  } catch {}
409
443
  });
410
444
  }
package/dist/index.js CHANGED
@@ -319,6 +319,23 @@ function gitCommit(options) {
319
319
  error: message`Commit ${value(input)} does not exist. Provide a valid commit SHA.`
320
320
  };
321
321
  }
322
+ }, async function* suggestCommit(dir, prefix) {
323
+ try {
324
+ const commits = await git.log({
325
+ fs: gitFs,
326
+ dir,
327
+ depth: 15
328
+ });
329
+ for (const commit of commits) if (commit.oid.startsWith(prefix)) {
330
+ const shortOid = commit.oid.slice(0, 7);
331
+ const firstLine = commit.commit.message.split("\n")[0];
332
+ yield {
333
+ kind: "literal",
334
+ text: shortOid,
335
+ description: message`${firstLine}`
336
+ };
337
+ }
338
+ } catch {}
322
339
  });
323
340
  }
324
341
  /**
@@ -368,13 +385,21 @@ function gitRef(options) {
368
385
  }
369
386
  }, async function* suggestRef(dir, prefix) {
370
387
  try {
371
- const [branches, tags] = await Promise.all([git.listBranches({
372
- fs: gitFs,
373
- dir
374
- }), git.listTags({
375
- fs: gitFs,
376
- dir
377
- })]);
388
+ const [branches, tags, commits] = await Promise.all([
389
+ git.listBranches({
390
+ fs: gitFs,
391
+ dir
392
+ }),
393
+ git.listTags({
394
+ fs: gitFs,
395
+ dir
396
+ }),
397
+ git.log({
398
+ fs: gitFs,
399
+ dir,
400
+ depth: 10
401
+ })
402
+ ]);
378
403
  for (const branch of branches) if (branch.startsWith(prefix)) yield {
379
404
  kind: "literal",
380
405
  text: branch
@@ -383,6 +408,15 @@ function gitRef(options) {
383
408
  kind: "literal",
384
409
  text: tag
385
410
  };
411
+ for (const commit of commits) if (commit.oid.startsWith(prefix)) {
412
+ const shortOid = commit.oid.slice(0, 7);
413
+ const firstLine = commit.commit.message.split("\n")[0];
414
+ yield {
415
+ kind: "literal",
416
+ text: shortOid,
417
+ description: message`${firstLine}`
418
+ };
419
+ }
386
420
  } catch {}
387
421
  });
388
422
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optique/git",
3
- "version": "0.9.0-dev.256+2840ea5d",
3
+ "version": "0.9.0-dev.258+a42f88c2",
4
4
  "description": "Git value parsers for Optique",
5
5
  "keywords": [
6
6
  "CLI",