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
faker.git.branch(): string
faker.git.branch() // 'feed-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? | Date | number | string | faker.defaultRefDate() | The date to use as reference point for the commit. |
Returns: string
faker.git.commitDate(options: {
refDate: Date | number | string
} = {}): string
faker.git.commitDate() // 'Mon Nov 7 14:40:58 2022 +0600'
faker.git.commitDate({ refDate: '2020-01-01' }) // 'Tue Dec 31 05:40:59 2019 -0400'
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? | 'CRLF' | 'LF' | 'CRLF' | Choose the end of line character to use.
|
options.merge? | boolean | faker.datatype.boolean({ probability: 0.2 }) | Set to |
options.refDate? | Date | number | string | new Date() | The date to use as reference point for the commit. |
Returns: string
faker.git.commitEntry(options: {
eol: 'CRLF' | 'LF',
merge: boolean,
refDate: Date | number | string
} = {}): string
faker.git.commitEntry()
// commit fe8c38a965d13d9794eb36918cb24cebe49a45c2
// Author: Marion Becker <Marion_Becker49@gmail.com>
// Date: Mon Nov 7 05:38:37 2022 -0600
//
// generate open-source system
Source
commitMessage
Generates a random commit message.
Available since v5.0.0
Returns: string
faker.git.commitMessage(): string
faker.git.commitMessage() // 'reboot cross-platform driver'
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
faker.git.commitSha(options: {
length: number
} = {}): string
faker.git.commitSha() // '2c6e3880fd94ddb7ef72d34e683cdc0c47bec6e6'
Source
shortSha
Deprecated
This method is deprecated and will be removed in a future version.
Use faker.git.commitSha({ length: 7 })
instead.
Generates a random commit sha (short).
Available since v5.0.0
Returns: string
faker.git.shortSha(): string
faker.git.shortSha() // '6155732'