@commitlint/read 19.2.1 → 19.4.0

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/lib/read.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  interface GetCommitMessageOptions {
2
2
  cwd?: string;
3
3
  from?: string;
4
+ fromLastTag?: boolean;
4
5
  to?: string;
5
6
  last?: boolean;
6
7
  edit?: boolean | string;
package/lib/read.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"read.d.ts","sourceRoot":"","sources":["../src/read.ts"],"names":[],"mappings":"AAQA,UAAU,uBAAuB;IAChC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,IAAI,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IACxB,UAAU,CAAC,EAAE,MAAM,CAAC;CACpB;AAGD,wBAA8B,iBAAiB,CAC9C,QAAQ,EAAE,uBAAuB,GAC/B,OAAO,CAAC,MAAM,EAAE,CAAC,CA8BnB"}
1
+ {"version":3,"file":"read.d.ts","sourceRoot":"","sources":["../src/read.ts"],"names":[],"mappings":"AAQA,UAAU,uBAAuB;IAChC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,IAAI,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IACxB,UAAU,CAAC,EAAE,MAAM,CAAC;CACpB;AAGD,wBAA8B,iBAAiB,CAC9C,QAAQ,EAAE,uBAAuB,GAC/B,OAAO,CAAC,MAAM,EAAE,CAAC,CA2DnB"}
package/lib/read.js CHANGED
@@ -4,22 +4,41 @@ import { getEditCommit } from './get-edit-commit.js';
4
4
  import { execa } from 'execa';
5
5
  // Get commit messages
6
6
  export default async function getCommitMessages(settings) {
7
- const { cwd, from, to, last, edit, gitLogArgs } = settings;
7
+ const { cwd, fromLastTag, to, last, edit, gitLogArgs } = settings;
8
+ let from = settings.from;
8
9
  if (edit) {
9
10
  return getEditCommit(cwd, edit);
10
11
  }
11
12
  if (last) {
12
- const gitCommandResult = await execa('git', [
13
- 'log',
14
- '-1',
15
- '--pretty=format:%B',
16
- ]);
13
+ const gitCommandResult = await execa('git', ['log', '-1', '--pretty=format:%B'], { cwd });
17
14
  let output = gitCommandResult.stdout;
18
15
  // strip output of extra quotation marks ("")
19
16
  if (output[0] == '"' && output[output.length - 1] == '"')
20
17
  output = output.slice(1, -1);
21
18
  return [output];
22
19
  }
20
+ if (!from && fromLastTag) {
21
+ const { stdout } = await execa('git', [
22
+ 'describe',
23
+ '--abbrev=40',
24
+ '--always',
25
+ '--first-parent',
26
+ '--long',
27
+ '--tags',
28
+ ], { cwd });
29
+ if (stdout.length === 40) {
30
+ // Hash only means no last tag. Use that as the from ref which
31
+ // results in a no-op.
32
+ from = stdout;
33
+ }
34
+ else {
35
+ // Description will be in the format: <tag>-<count>-g<hash>
36
+ // Example: v3.2.0-11-g9057371a52adaae5180d93fe4d0bb808d874b9fb
37
+ // Minus zero based (1), dash (1), "g" prefix (1), hash (40) = -43
38
+ const tagSlice = stdout.lastIndexOf('-', stdout.length - 43);
39
+ from = stdout.slice(0, tagSlice);
40
+ }
41
+ }
23
42
  let gitOptions = { from, to };
24
43
  if (gitLogArgs) {
25
44
  gitOptions = {
package/lib/read.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"read.js","sourceRoot":"","sources":["../src/read.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,UAAU,CAAC;AAGhC,OAAO,EAAC,iBAAiB,EAAC,MAAM,0BAA0B,CAAC;AAC3D,OAAO,EAAC,aAAa,EAAC,MAAM,sBAAsB,CAAC;AAEnD,OAA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MAAM,CAAC;QACf,CAAC;aAAM,CAAC;YACP,2DAA2D;YAC3D,+DAA+D;YAC/D,kEAAkE;YAClE,MAAM,QAAQ,GAAG,MAAM,CAAC,WAAW,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;YAE7D,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC;QAClC,CAAC;IACF,CAAC;IAED,IAAI,UAAU,GAAe,EAAC,IAAI,EAAE,EAAE,EAAC,CAAC;IACxC,IAAI,UAAU,EAAE,CAAC;QAChB,UAAU,GAAG;YACZ,GAAG,QAAQ,CAAC,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YAClC,IAAI;YACJ,EAAE;SACF,CAAC;IACH,CAAC;IAED,OAAO,iBAAiB,CAAC,UAAU,EAAE,EAAC,GAAG,EAAC,CAAC,CAAC;AAC7C,CAAC"}
@@ -1,4 +1,3 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
1
  import { Readable } from 'stream';
3
2
  export declare function streamToPromise(stream: Readable): Promise<string[]>;
4
3
  //# sourceMappingURL=stream-to-promise.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"stream-to-promise.d.ts","sourceRoot":"","sources":["../src/stream-to-promise.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,QAAQ,CAAC;AAEhC,wBAAgB,eAAe,CAAC,MAAM,EAAE,QAAQ,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAQnE"}
1
+ {"version":3,"file":"stream-to-promise.d.ts","sourceRoot":"","sources":["../src/stream-to-promise.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,QAAQ,CAAC;AAEhC,wBAAgB,eAAe,CAAC,MAAM,EAAE,QAAQ,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAQnE"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@commitlint/read",
3
3
  "type": "module",
4
- "version": "19.2.1",
4
+ "version": "19.4.0",
5
5
  "description": "Read commit messages from a specified range or last edit",
6
6
  "main": "lib/read.js",
7
7
  "types": "lib/read.d.ts",
@@ -48,5 +48,5 @@
48
48
  "git-raw-commits": "^4.0.0",
49
49
  "minimist": "^1.2.8"
50
50
  },
51
- "gitHead": "172cb52844cdb0dd1af5a47f0101c48320d90500"
51
+ "gitHead": "bac2288cc7de5bb6f41939d1c562193c74ce16d5"
52
52
  }