@mimik/git-hooks
git-hooks
Example
import { commitCheckMsg, validateCommit } from '@mimik/git-hooks';
// or
import gitHooks from '@mimik/git-hooks';
- git-hooks
- ~validateCommit(branchName, commitMsg) ⇒
Object - async
- ~commitCheckMsg([options]) ⇒
Promise.<null>
- ~commitCheckMsg([options]) ⇒
- ~validateCommit(branchName, commitMsg) ⇒
git-hooks~validateCommit(branchName, commitMsg) ⇒ Object
Validates a commit message against a branch name's JIRA ticket number.
The branch name must contain a JIRA ticket in the format PROJ-123- (with a trailing dash),
matching the convention for JIRA-generated branches (e.g. feature/BES-1219-my-branch).
The commit message must start with the same ticket number followed by a space and a
description of at least 10 characters.
Kind: inner method of git-hooks
Returns: Object - Result with valid flag and error message (null when valid).
| Param | Type | Description |
|---|---|---|
| branchName | string |
The current git branch name (must contain PROJ-123- pattern with trailing dash). |
| commitMsg | string |
The commit message to validate (must start with matching ticket number). |
Example
import { validateCommit } from '@mimik/git-hooks';
const result = validateCommit('feature/BES-1219-my-branch', 'BES-1219 implement user authentication');
// result: { valid: true, error: null }
git-hooks~commitCheckMsg([options]) ⇒ Promise.<null>
Checks the validity of the commit message against the current branch's JIRA ticket number.
Reads the commit message from the file at process.argv[2].
Kind: inner method of git-hooks
Returns: Promise.<null> - Resolves with null on success. On failure, the process exits with code 1 (the promise never resolves).
Category: async
| Param | Type | Description |
|---|---|---|
| [options] | object |
Internal options for dependency injection (testing). |
| [options.git] | function |
Git client factory (defaults to simpleGit). |
Example
import { commitCheckMsg } from '@mimik/git-hooks';
// or
import gitHooks from '@mimik/git-hooks';