Git
Module to generate git related entries.
Overview
commitEntry()
generates a random commit entry as printed by git log
. This includes a commit hash commitSha()
, author, date commitDate()
, and commit message commitMessage()
. You can also generate a random branch name with branch()
.
branch
Generates a random branch name.
Available since v5.0.0
Returns: string
function branch(): string;
Examples
faker.git.branch() // 'matrix-parse'
Source
commitDate
Generates a date string for a git commit using the same format as git log
.
Available since v8.0.0
Parameters
Name | Type | Default | Description |
---|---|---|---|
options | { ... } | {} | The optional options object. |
options.refDate? | string | number | Date | faker.defaultRefDate() | The date to use as reference point for the commit. |
Returns: string
function commitDate(
options: {
refDate?: string | Date | number;
} = {}
): string;
Examples
faker.git.commitDate() // 'Tue Dec 31 12:10:16 2024 +0600'
faker.git.commitDate({ refDate: '2020-01-01' }) // 'Tue Dec 31 14:27:58 2019 +0200'
Source
commitEntry
Generates a random commit entry as printed by git log
.
Available since v5.0.0
Parameters
Name | Type | Default | Description |
---|---|---|---|
options | { ... } | {} | Options for the commit entry. |
options.eol? | 'LF' | 'CRLF' | 'CRLF' | Choose the end of line character to use.
|
options.merge? | boolean | faker.datatype.boolean({ probability: 0.2 }) | Set to |
options.refDate? | string | number | Date | new Date() | The date to use as reference point for the commit. |
Returns: string
function commitEntry(
options: {
merge?: boolean;
eol?: 'LF' | 'CRLF';
refDate?: string | Date | number;
} = {}
): string;
Examples
faker.git.commitEntry()
// 'commit fdb9e9df8bbce110cbdfbab2e3eb95bac0dddef7
// Author: Humberto Beier <Humberto.Beier98@yahoo.com>
// Date: Tue Dec 31 04:00:46 2024 -0800
//
// override cross-platform hard drive
// '
Source
commitMessage
Generates a random commit message.
Available since v5.0.0
Returns: string
function commitMessage(): string;
Examples
faker.git.commitMessage() // 'input optical microchip'
Source
commitSha
Generates a random commit sha.
By default, the length of the commit sha is 40 characters.
For a shorter commit sha, use the length
option.
Usual short commit sha length is:
- 7 for GitHub
- 8 for GitLab
Available since v5.0.0
Parameters
Name | Type | Default | Description |
---|---|---|---|
options | { ... } | {} | Options for the commit sha. |
options.length? | number | 40 | The length of the commit sha. |
Returns: string
function commitSha(
options: {
length?: number;
} = {}
): string;
Examples
faker.git.commitSha() // 'cfdb9e9df8bbce110cbdfbab2e3eb95bac0dddef'
faker.git.commitSha({ length: 7 }) // '79f1ee4'
faker.git.commitSha({ length: 8 }) // '268c9f24'