Skip to main content
Module

x/commit/mod.ts>Options

✍️ Parser for the conventional commits specification
Latest
interface Options
import { type Options } from "https://deno.land/x/commit@0.1.5/mod.ts";

Properties

optional
mergePattern: Pattern

Pattern to match merge headers. EG: branch merge, GitHub or GitLab like pull requests headers. When a merge header is parsed, the next line is used for conventional header parsing.

For example, if we have a commit

Merge pull request #1 from user/feature/feature-name

feat(scope): broadcast $destroy event on scope destruction

We can parse it with these options and the default headerPattern:

{
 mergePattern: /^Merge pull request #(\d+) from (.*)$/,
 mergeCorrespondence: ['id', 'source']
}
optional
mergeCorrespondence: Correspondence

Used to define what capturing group of mergePattern.

If it's a string it will be converted to an array separated by a comma.

optional
headerPattern: Pattern

Used to match header pattern.

optional
headerCorrespondence: Correspondence

Used to define what capturing group of headerPattern captures what header part. The order of the array should correspond to the order of headerPattern's capturing group. If the part is not captured it is null. If it's a string it will be converted to an array separated by a comma.

optional
referenceActions: Actions

Keywords to reference an issue. This value is case insensitive. If it's a string it will be converted to an array separated by a comma.

Set it to null to reference an issue without any action.

optional
issuePrefixes: Prefixes

The prefixes of an issue. EG: In gh-123 gh- is the prefix.

optional
issuePrefixesCaseSensitive: boolean

Used to define if issuePrefixes should be considered case sensitive.

optional
noteKeywords: Keywords

Keywords for important notes. This value is case insensitive. If it's a string it will be converted to an array separated by a comma.

optional
fieldPattern: Pattern

Pattern to match other fields.

optional
revertPattern: Pattern

Pattern to match what this commit reverts.

optional
revertCorrespondence: Correspondence

Used to define what capturing group of revertPattern captures what reverted commit fields. The order of the array should correspond to the order of revertPattern's capturing group.

For example, if we had commit

Revert "throw an error if a callback is passed"

This reverts commit 9bb4d6c.

If configured correctly, the parsed result would be

{
 revert: {
   header: 'throw an error if a callback is passed',
   hash: '9bb4d6c'
 }
}

It implies that this commit reverts a commit with header 'throw an error if a callback is passed' and hash '9bb4d6c'.

If it's a string it will be converted to an array separated by a comma.

optional
commentChar: string | null

What commentChar to use. By default it is null, so no comments are stripped. Set to # if you pass the contents of .git/COMMIT_EDITMSG directly.

If you have configured the git commentchar via git config core.commentchar you'll want to pass what you have set there.

optional
warn: (message?: string) => void | boolean

What warn function to use. For example, console.warn.bind(console) or grunt.log.writeln. By default, it's a noop. If it is true, it will error if commit cannot be parsed (strict).